use crate::{ commands::{ Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError, }, Request, }; pub struct SwapId; impl Command for SwapId { type Response = (); const COMMAND: &'static str = "swapid"; fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> { let songid1 = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let songid1 = songid1 .parse() .map_err(|_| RequestParserError::SyntaxError(0, songid1.to_string()))?; let songid2 = parts.next().ok_or(RequestParserError::UnexpectedEOF)?; let songid2 = songid2 .parse() .map_err(|_| RequestParserError::SyntaxError(0, songid2.to_string()))?; debug_assert!(parts.next().is_none()); Ok((Request::SwapId(songid1, songid2), "")) } fn parse_response( parts: ResponseAttributes<'_>, ) -> Result { debug_assert!(parts.is_empty()); Ok(()) } }