Files
empidee/src/commands/queue/plchangesposid.rs
2026-01-09 13:31:16 +09:00

56 lines
1.6 KiB
Rust

use serde::{Deserialize, Serialize};
use crate::{
Request,
commands::{
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
},
common::{Version, WindowRange},
};
pub struct PlChangesPosId;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct PlChangesPosIdRequest {
pub version: Version,
pub window: Option<WindowRange>,
}
impl Command for PlChangesPosId {
type Request = PlChangesPosIdRequest;
type Response = ();
const COMMAND: &'static str = "plchangesposid";
fn serialize_request(&self, request: Self::Request) -> String {
match request.window {
Some(window) => format!("{} {} {}", Self::COMMAND, request.version, window),
None => format!("{} {}", Self::COMMAND, request.version),
}
}
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
let version = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
let version = version
.parse()
.map_err(|_| RequestParserError::SyntaxError(0, version.to_string()))?;
let window = parts
.next()
.map(|w| {
w.parse()
.map_err(|_| RequestParserError::SyntaxError(0, w.to_string()))
})
.transpose()?;
debug_assert!(parts.next().is_none());
Ok((Request::PlChangesPosId(version, window), ""))
}
fn parse_response(
parts: ResponseAttributes<'_>,
) -> Result<Self::Response, ResponseParserError<'_>> {
unimplemented!()
}
}