commands: use real Filter
type
This commit is contained in:
parent
1da222857d
commit
bc1a4f11a5
@ -2,6 +2,7 @@ use crate::{
|
||||
commands::{
|
||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||
},
|
||||
filter::parse_filter,
|
||||
Request,
|
||||
};
|
||||
|
||||
@ -12,8 +13,7 @@ impl Command for PlaylistFind {
|
||||
const COMMAND: &'static str = "playlistfind";
|
||||
|
||||
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
|
||||
let filter = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let filter = filter.to_string();
|
||||
let filter = parse_filter(&mut parts)?;
|
||||
|
||||
let mut sort_or_window = parts.next();
|
||||
let mut sort = None;
|
||||
|
@ -2,6 +2,7 @@ use crate::{
|
||||
commands::{
|
||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||
},
|
||||
filter::parse_filter,
|
||||
Request,
|
||||
};
|
||||
|
||||
@ -12,10 +13,7 @@ impl Command for PlaylistSearch {
|
||||
const COMMAND: &'static str = "playlistsearch";
|
||||
|
||||
fn parse_request(mut parts: std::str::SplitWhitespace<'_>) -> RequestParserResult<'_> {
|
||||
let filter = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let filter = filter
|
||||
.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(0, filter.to_string()))?;
|
||||
let filter = parse_filter(&mut parts)?;
|
||||
|
||||
let mut sort_or_window = parts.next();
|
||||
let mut sort = None;
|
||||
|
@ -3,7 +3,8 @@ use crate::{
|
||||
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||
ResponseParserError,
|
||||
},
|
||||
common::{Filter, PlaylistName},
|
||||
common::PlaylistName,
|
||||
filter::parse_filter,
|
||||
};
|
||||
|
||||
pub struct SearchPlaylist;
|
||||
@ -18,10 +19,7 @@ impl Command for SearchPlaylist {
|
||||
.parse::<PlaylistName>()
|
||||
.map_err(|_| RequestParserError::SyntaxError(0, name.to_owned()))?;
|
||||
|
||||
let filter = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let filter = filter
|
||||
.parse::<Filter>()
|
||||
.map_err(|_| RequestParserError::SyntaxError(0, filter.to_owned()))?;
|
||||
let filter = parse_filter(&mut parts)?;
|
||||
|
||||
let range = parts
|
||||
.next()
|
||||
|
@ -95,7 +95,6 @@ pub type TagName = String;
|
||||
pub type TagValue = String;
|
||||
pub type Uri = String;
|
||||
pub type Path = String;
|
||||
pub type Filter = String;
|
||||
pub type Sort = String;
|
||||
pub type Version = String;
|
||||
pub type Feature = String;
|
||||
|
@ -1,11 +1,20 @@
|
||||
use crate::common::{Priority, Tag};
|
||||
use std::str::SplitWhitespace;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::RequestParserError,
|
||||
common::{Priority, Tag},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum CaseSensitivity {
|
||||
CaseSensitive,
|
||||
CaseInsensitive,
|
||||
CommandDependent,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum Filter {
|
||||
Not(Box<Filter>),
|
||||
And(Box<Filter>, Box<Filter>),
|
||||
@ -30,3 +39,7 @@ pub enum Filter {
|
||||
},
|
||||
PrioCmp(Priority),
|
||||
}
|
||||
|
||||
pub fn parse_filter(parts: &mut SplitWhitespace<'_>) -> Result<Filter, RequestParserError> {
|
||||
todo!()
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::common::*;
|
||||
|
||||
use crate::commands::*;
|
||||
use crate::filter::Filter;
|
||||
|
||||
// TODO: SingleLineString
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user