Implement some more commands

This commit is contained in:
2024-11-30 17:12:49 +01:00
parent 8461542735
commit 2ca3cd40bc
31 changed files with 926 additions and 10 deletions
+36
View File
@@ -0,0 +1,36 @@
use crate::{
commands::{
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
},
Request,
};
pub struct MoveId;
impl Command for MoveId {
type Response = ();
const COMMAND: &'static str = "moveid";
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
let id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
let id = id
.parse()
.map_err(|_| RequestParserError::SyntaxError(0, id.to_string()))?;
let to = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
let to = to
.parse()
.map_err(|_| RequestParserError::SyntaxError(0, to.to_string()))?;
debug_assert!(parts.next().is_none());
Ok((Request::MoveId(id, to), ""))
}
fn parse_response(
parts: ResponseAttributes<'_>,
) -> Result<Self::Response, ResponseParserError> {
debug_assert!(parts.is_empty());
Ok(())
}
}