35 lines
929 B
Rust
35 lines
929 B
Rust
use crate::{
|
|
commands::{
|
|
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
|
ResponseParserError,
|
|
},
|
|
common::SongPosition,
|
|
};
|
|
|
|
pub struct Play;
|
|
|
|
impl Command for Play {
|
|
type Response = ();
|
|
const COMMAND: &'static str = "play";
|
|
|
|
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
|
|
let songpos = match parts.next() {
|
|
Some(s) => s
|
|
.parse::<SongPosition>()
|
|
.map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?,
|
|
None => return Err(RequestParserError::UnexpectedEOF),
|
|
};
|
|
|
|
debug_assert!(parts.next().is_none());
|
|
|
|
Ok((Request::Play(songpos), ""))
|
|
}
|
|
|
|
fn parse_response(
|
|
parts: ResponseAttributes<'_>,
|
|
) -> Result<Self::Response, ResponseParserError> {
|
|
debug_assert!(parts.is_empty());
|
|
Ok(())
|
|
}
|
|
}
|