use crate::{ commands::{ Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError, }, Request, }; pub struct PrioId; impl Command for PrioId { type Response = (); const COMMAND: &'static str = "prioid"; fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> { let prio = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let prio = prio .parse() .map_err(|_| RequestParserError::SyntaxError(0, prio.to_string()))?; let songids = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; // TODO: This is just a guess to satisfy compilation, double check it let songids = songids .split(',') .map(|s| { s.parse() .map_err(|_| RequestParserError::SyntaxError(0, s.to_string())) }) .collect::, RequestParserError>>()?; debug_assert!(parts.next().is_none()); Ok((Request::PrioId(prio, songids), "")) } fn parse_response( parts: ResponseAttributes<'_>, ) -> Result { debug_assert!(parts.is_empty()); Ok(()) } }