refactor: pull version into const
This commit is contained in:
parent
6f103ace64
commit
e859b6ce0a
|
@ -10,14 +10,16 @@ use crate::{
|
||||||
WsStream,
|
WsStream,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const VERSION: u32 = 1;
|
||||||
|
|
||||||
pub async fn version(conn: &mut WsStream, number: u32, req: VersionRequest) -> Result<bool> {
|
pub async fn version(conn: &mut WsStream, number: u32, req: VersionRequest) -> Result<bool> {
|
||||||
if req.version != 1 {
|
if req.version != VERSION {
|
||||||
send(conn, number, ErrorResponse::new(None, "unsupported version")).await?;
|
send(conn, number, ErrorResponse::new(None, "unsupported version")).await?;
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
send(conn, number, VersionResponse {
|
send(conn, number, VersionResponse {
|
||||||
version: 1,
|
version: VERSION,
|
||||||
}).await?;
|
}).await?;
|
||||||
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user