Files
empidee/src/commands/queue/playlistfind.rs
h7x4 e910d29aa4
Some checks failed
Build and test / build (push) Successful in 59s
Build and test / check (push) Failing after 1m2s
Build and test / test (push) Successful in 1m42s
Build and test / docs (push) Successful in 1m19s
Rust edition 2024
2025-02-26 16:39:34 +01:00

50 lines
1.4 KiB
Rust

use crate::{
Request,
commands::{
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
},
filter::parse_filter,
};
pub struct PlaylistFind;
impl Command for PlaylistFind {
type Response = ();
const COMMAND: &'static str = "playlistfind";
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
let filter = parse_filter(&mut parts)?;
let mut sort_or_window = parts.next();
let mut sort = None;
if let Some("sort") = sort_or_window {
sort = Some(
parts
.next()
.ok_or(RequestParserError::UnexpectedEOF)?
.to_string(),
);
sort_or_window = parts.next();
}
let mut window = None;
if let Some("window") = sort_or_window {
let w = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
window = Some(
w.parse()
.map_err(|_| RequestParserError::SyntaxError(0, w.to_string()))?,
);
}
debug_assert!(parts.next().is_none());
Ok((Request::PlaylistFind(filter, sort, window), ""))
}
fn parse_response(
_parts: ResponseAttributes<'_>,
) -> Result<Self::Response, ResponseParserError> {
unimplemented!()
}
}