39 lines
1.1 KiB
Rust
39 lines
1.1 KiB
Rust
use crate::{
|
|
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
|
common::types::Seconds,
|
|
request_tokenizer::RequestTokenizer,
|
|
response_tokenizer::ResponseAttributes,
|
|
};
|
|
|
|
pub struct Crossfade;
|
|
|
|
impl Command for Crossfade {
|
|
type Request = Seconds;
|
|
type Response = ();
|
|
const COMMAND: &'static str = "crossfade";
|
|
|
|
fn serialize_request(&self, request: Self::Request) -> String {
|
|
format!("{} {}", Self::COMMAND, request)
|
|
}
|
|
|
|
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
|
let seconds = match parts.next() {
|
|
Some(s) => s
|
|
.parse::<Seconds>()
|
|
.map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?,
|
|
None => return Err(RequestParserError::UnexpectedEOF),
|
|
};
|
|
|
|
debug_assert!(parts.next().is_none());
|
|
|
|
Ok((Request::Crossfade(seconds), ""))
|
|
}
|
|
|
|
fn parse_response(
|
|
parts: ResponseAttributes<'_>,
|
|
) -> Result<Self::Response, ResponseParserError<'_>> {
|
|
debug_assert!(parts.is_empty());
|
|
Ok(())
|
|
}
|
|
}
|