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