refactor: pull version into const

This commit is contained in:
Anna 2022-07-09 20:53:15 -04:00
parent 73e2cec4e0
commit 73b3ae8a1f
1 changed files with 4 additions and 2 deletions

View File

@ -10,14 +10,16 @@ use crate::{
WsStream,
};
const VERSION: u32 = 1;
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?;
return Ok(false);
}
send(conn, number, VersionResponse {
version: 1,
version: VERSION,
}).await?;
Ok(true)