commands: parse to Self::Request
This commit is contained in:
@@ -60,7 +60,7 @@ pub trait Command {
|
||||
/// ```ignore
|
||||
/// arg1 "arg2 arg3"
|
||||
/// ```
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_>;
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError>;
|
||||
|
||||
/// Parse the raw request string into a request and the remaining unparsed string.
|
||||
/// This assumes the raw string starts with the command name, e.g.
|
||||
@@ -68,7 +68,7 @@ pub trait Command {
|
||||
/// ```ignore
|
||||
/// command_name arg1 "arg2 arg3"
|
||||
/// ```
|
||||
fn parse_raw_request(raw: &str) -> RequestParserResult<'_> {
|
||||
fn parse_raw_request(raw: &str) -> Result<(Self::Request, &str), RequestParserError> {
|
||||
let (line, rest) = raw
|
||||
.split_once('\n')
|
||||
.ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
@@ -81,7 +81,7 @@ pub trait Command {
|
||||
|
||||
debug_assert!(command_name == Self::COMMAND);
|
||||
|
||||
Self::parse_request(tokenized).map(|(req, _)| (req, rest))
|
||||
Self::parse_request(tokenized).map(|req| (req, rest))
|
||||
}
|
||||
|
||||
/// Parse the response from its tokenized parts.
|
||||
@@ -94,7 +94,7 @@ pub trait Command {
|
||||
}
|
||||
}
|
||||
|
||||
pub type RequestParserResult<'a> = Result<(Request, &'a str), RequestParserError>;
|
||||
// pub type RequestParserResult<'a> = ;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum RequestParserError {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::AudioOutputId,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -18,7 +18,7 @@ impl Command for DisableOutput {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let output_id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let output_id = output_id
|
||||
.parse()
|
||||
@@ -26,7 +26,7 @@ impl Command for DisableOutput {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::DisableOutput(output_id), ""))
|
||||
Ok(output_id)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::AudioOutputId,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -18,7 +18,7 @@ impl Command for EnableOutput {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let output_id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let output_id = output_id
|
||||
.parse()
|
||||
@@ -26,7 +26,7 @@ impl Command for EnableOutput {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::EnableOutput(output_id), ""))
|
||||
Ok(output_id)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::AudioOutputId,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
@@ -31,9 +31,9 @@ impl Command for Outputs {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::Outputs, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::AudioOutputId,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -31,7 +31,7 @@ impl Command for OutputSet {
|
||||
)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let output_id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let output_id = output_id
|
||||
.parse()
|
||||
@@ -41,14 +41,11 @@ impl Command for OutputSet {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((
|
||||
Request::OutputSet(
|
||||
output_id,
|
||||
attribute_name.to_string(),
|
||||
attribute_value.to_string(),
|
||||
),
|
||||
"",
|
||||
))
|
||||
Ok(OutputSetRequest {
|
||||
output_id,
|
||||
attribute_name: attribute_name.to_string(),
|
||||
attribute_value: attribute_value.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::AudioOutputId,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -18,7 +18,7 @@ impl Command for ToggleOutput {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let output_id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let output_id = output_id
|
||||
.parse()
|
||||
@@ -26,7 +26,7 @@ impl Command for ToggleOutput {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::ToggleOutput(output_id), ""))
|
||||
Ok(output_id)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::ChannelName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
@@ -23,10 +23,10 @@ impl Command for Channels {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Channels, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::ChannelName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
@@ -26,10 +26,10 @@ impl Command for ReadMessages {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::ReadMessages, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::ChannelName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -24,7 +24,7 @@ impl Command for SendMessage {
|
||||
format!("{} {} {}", Self::COMMAND, request.channel, request.message)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let channel = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let channel = channel
|
||||
.parse()
|
||||
@@ -35,7 +35,7 @@ impl Command for SendMessage {
|
||||
|
||||
debug_assert!(!message.is_empty());
|
||||
|
||||
Ok((Request::SendMessage(channel, message), ""))
|
||||
Ok(SendMessageRequest { channel, message })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::ChannelName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -16,7 +16,7 @@ impl Command for Subscribe {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let channel_name = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let channel_name = channel_name
|
||||
.parse()
|
||||
@@ -24,7 +24,7 @@ impl Command for Subscribe {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Subscribe(channel_name), ""))
|
||||
Ok(channel_name)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::ChannelName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -16,7 +16,7 @@ impl Command for Unsubscribe {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let channel_name = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let channel_name = channel_name
|
||||
.parse()
|
||||
@@ -24,7 +24,7 @@ impl Command for Unsubscribe {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Unsubscribe(channel_name), ""))
|
||||
Ok(channel_name)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -15,13 +15,13 @@ impl Command for BinaryLimit {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let limit = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let limit = limit
|
||||
.parse()
|
||||
.map_err(|_| RequestParserError::SyntaxError(0, limit.to_string()))?;
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::BinaryLimit(limit), ""))
|
||||
Ok(limit)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -15,9 +15,9 @@ impl Command for Close {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::Close, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -15,9 +15,9 @@ impl Command for Kill {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::Kill, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -15,13 +15,13 @@ impl Command for Password {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let password = parts
|
||||
.next()
|
||||
.ok_or(RequestParserError::UnexpectedEOF)?
|
||||
.to_string();
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::Password(password), ""))
|
||||
Ok(password)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -15,9 +15,9 @@ impl Command for Ping {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::Ping, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
};
|
||||
@@ -18,9 +17,9 @@ impl Command for Protocol {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::Protocol, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -16,9 +15,9 @@ impl Command for ProtocolAll {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::ProtocolAll, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
};
|
||||
@@ -18,9 +17,9 @@ impl Command for ProtocolAvailable {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::ProtocolAvailable, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -16,9 +15,9 @@ impl Command for ProtocolClear {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::ProtocolClear, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Feature,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -19,7 +18,7 @@ impl Command for ProtocolDisable {
|
||||
format!("{} {}", Self::COMMAND, request.join(" "))
|
||||
}
|
||||
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let mut parts = parts.peekable();
|
||||
if parts.peek().is_none() {
|
||||
return Err(RequestParserError::UnexpectedEOF);
|
||||
@@ -27,7 +26,7 @@ impl Command for ProtocolDisable {
|
||||
|
||||
let features = parts.map(|s| s.to_string()).collect::<Vec<String>>();
|
||||
|
||||
Ok((Request::ProtocolDisable(features), ""))
|
||||
Ok(features)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Feature,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -19,7 +18,7 @@ impl Command for ProtocolEnable {
|
||||
format!("{} {}", Self::COMMAND, request.join(" "))
|
||||
}
|
||||
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let mut parts = parts.peekable();
|
||||
if parts.peek().is_none() {
|
||||
return Err(RequestParserError::UnexpectedEOF);
|
||||
@@ -27,7 +26,7 @@ impl Command for ProtocolEnable {
|
||||
|
||||
let features = parts.map(|s| s.to_string()).collect::<Vec<String>>();
|
||||
|
||||
Ok((Request::ProtocolEnable(features), ""))
|
||||
Ok(features)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
};
|
||||
@@ -17,9 +17,9 @@ impl Command for TagTypes {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::TagTypes, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -16,9 +15,9 @@ impl Command for TagTypesAll {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::TagTypesAll, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
};
|
||||
@@ -18,9 +17,9 @@ impl Command for TagTypesAvailable {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::TagTypesAvailable, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -16,9 +15,9 @@ impl Command for TagTypesClear {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::TagTypesClear, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::TagName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -19,7 +18,7 @@ impl Command for TagTypesDisable {
|
||||
format!("{} {}", Self::COMMAND, request.join(" "))
|
||||
}
|
||||
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let mut parts = parts.peekable();
|
||||
if parts.peek().is_none() {
|
||||
return Err(RequestParserError::UnexpectedEOF);
|
||||
@@ -27,7 +26,7 @@ impl Command for TagTypesDisable {
|
||||
|
||||
let tag_types = parts.map(|s| s.to_string()).collect::<Vec<String>>();
|
||||
|
||||
Ok((Request::TagTypesDisable(tag_types), ""))
|
||||
Ok(tag_types)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::TagName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -19,7 +18,7 @@ impl Command for TagTypesEnable {
|
||||
format!("{} {}", Self::COMMAND, request.join(" "))
|
||||
}
|
||||
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let mut parts = parts.peekable();
|
||||
if parts.peek().is_none() {
|
||||
return Err(RequestParserError::UnexpectedEOF);
|
||||
@@ -27,7 +26,7 @@ impl Command for TagTypesEnable {
|
||||
|
||||
let tag_types = parts.map(|s| s.to_string()).collect::<Vec<String>>();
|
||||
|
||||
Ok((Request::TagTypesEnable(tag_types), ""))
|
||||
Ok(tag_types)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::TagName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -19,7 +18,7 @@ impl Command for TagTypesReset {
|
||||
format!("{} {}", Self::COMMAND, request.join(" "))
|
||||
}
|
||||
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let mut parts = parts.peekable();
|
||||
if parts.peek().is_none() {
|
||||
return Err(RequestParserError::UnexpectedEOF);
|
||||
@@ -28,7 +27,7 @@ impl Command for TagTypesReset {
|
||||
// TODO: verify that the tag types are split by whitespace
|
||||
let tag_types = parts.map(|s| s.to_string()).collect::<Vec<String>>();
|
||||
|
||||
Ok((Request::TagTypesReset(tag_types), ""))
|
||||
Ok(tag_types)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -15,9 +15,9 @@ impl Command for Next {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::Next, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -19,12 +19,12 @@ impl Command for Pause {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let result = match parts.next() {
|
||||
Some("0") => Ok((Request::Pause(Some(false)), "")),
|
||||
Some("1") => Ok((Request::Pause(Some(true)), "")),
|
||||
Some("0") => Ok(Some(false)),
|
||||
Some("1") => Ok(Some(true)),
|
||||
Some(s) => Err(RequestParserError::SyntaxError(0, s.to_string())),
|
||||
None => Ok((Request::Pause(None), "")),
|
||||
None => Ok(None),
|
||||
};
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::SongPosition,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -16,7 +16,7 @@ impl Command for Play {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let songpos = match parts.next() {
|
||||
Some(s) => s
|
||||
.parse::<SongPosition>()
|
||||
@@ -26,7 +26,7 @@ impl Command for Play {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Play(songpos), ""))
|
||||
Ok(songpos)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::SongId,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -16,7 +16,7 @@ impl Command for PlayId {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let songid = match parts.next() {
|
||||
Some(s) => s
|
||||
.parse::<SongId>()
|
||||
@@ -26,7 +26,7 @@ impl Command for PlayId {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::PlayId(songid), ""))
|
||||
Ok(songid)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -15,9 +15,9 @@ impl Command for Previous {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::Previous, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{SongPosition, TimeWithFractions},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -24,7 +24,7 @@ impl Command for Seek {
|
||||
format!("{} {} {}", Self::COMMAND, request.songpos, request.time)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let songpos = match parts.next() {
|
||||
Some(s) => s
|
||||
.parse::<SongPosition>()
|
||||
@@ -41,7 +41,7 @@ impl Command for Seek {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Seek(songpos, time), ""))
|
||||
Ok(SeekRequest { songpos, time })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||
ResponseParserError,
|
||||
},
|
||||
commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError},
|
||||
common::types::{SeekMode, TimeWithFractions},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
};
|
||||
@@ -33,7 +30,7 @@ impl Command for SeekCur {
|
||||
format!("{} {}", Self::COMMAND, time_str)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let time_raw = match parts.next() {
|
||||
Some(t) => t,
|
||||
None => return Err(RequestParserError::UnexpectedEOF),
|
||||
@@ -62,7 +59,7 @@ impl Command for SeekCur {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::SeekCur(mode, time), ""))
|
||||
Ok(SeekCurRequest { mode, time })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{SongId, TimeWithFractions},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -24,7 +24,7 @@ impl Command for SeekId {
|
||||
format!("{} {} {}", Self::COMMAND, request.songid, request.time)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let songid = match parts.next() {
|
||||
Some(s) => s
|
||||
.parse::<SongId>()
|
||||
@@ -41,7 +41,7 @@ impl Command for SeekId {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::SeekId(songid, time), ""))
|
||||
Ok(SeekIdRequest { songid, time })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -15,9 +15,9 @@ impl Command for Stop {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::Stop, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
};
|
||||
@@ -16,9 +15,9 @@ impl Command for ListMounts {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::ListMounts, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
};
|
||||
@@ -20,9 +19,9 @@ impl Command for ListNeighbors {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::ListNeighbors, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -24,7 +23,7 @@ impl Command for Mount {
|
||||
format!("{} {} {}", Self::COMMAND, request.path, request.uri)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let path = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let path = path
|
||||
.parse()
|
||||
@@ -37,7 +36,7 @@ impl Command for Mount {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Mount(path, uri), ""))
|
||||
Ok(MountRequest { path, uri })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -18,7 +17,7 @@ impl Command for Unmount {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let path = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let path = path
|
||||
.parse()
|
||||
@@ -26,7 +25,7 @@ impl Command for Unmount {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Unmount(path), ""))
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{Offset, Uri},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property, get_property},
|
||||
@@ -32,7 +32,7 @@ impl Command for AlbumArt {
|
||||
format!("{} {} {}", Self::COMMAND, request.uri, request.offset)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = match parts.next() {
|
||||
Some(s) => s,
|
||||
None => return Err(RequestParserError::UnexpectedEOF),
|
||||
@@ -47,7 +47,10 @@ impl Command for AlbumArt {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::AlbumArt(uri.to_string(), offset), ""))
|
||||
Ok(AlbumArtRequest {
|
||||
uri: uri.to_string(),
|
||||
offset,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::GroupType,
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -37,7 +37,7 @@ impl Command for Count {
|
||||
cmd
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let filter = match parts.next() {
|
||||
Some(f) => {
|
||||
Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))?
|
||||
@@ -59,7 +59,7 @@ impl Command for Count {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Count(filter, group), ""))
|
||||
Ok(CountRequest { filter, group })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{Sort, WindowRange},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -36,7 +36,7 @@ impl Command for Find {
|
||||
cmd
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let filter = match parts.next() {
|
||||
Some(f) => {
|
||||
Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))?
|
||||
@@ -66,7 +66,11 @@ impl Command for Find {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Find(filter, sort, window), ""))
|
||||
Ok(FindRequest {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{SongPosition, Sort, WindowRange},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -37,7 +37,7 @@ impl Command for FindAdd {
|
||||
cmd
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let filter = match parts.next() {
|
||||
Some(f) => {
|
||||
Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))?
|
||||
@@ -77,7 +77,12 @@ impl Command for FindAdd {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::FindAdd(filter, sort, window, position), ""))
|
||||
Ok(FindAddRequest {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
position,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Uri,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
||||
@@ -25,7 +25,7 @@ impl Command for GetFingerprint {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let uri = uri
|
||||
.parse()
|
||||
@@ -33,7 +33,7 @@ impl Command for GetFingerprint {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::GetFingerprint(uri), ""))
|
||||
Ok(uri)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{GroupType, TagName, WindowRange},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -39,7 +39,7 @@ impl Command for List {
|
||||
cmd
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let tagname = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let tagname = tagname
|
||||
.parse()
|
||||
@@ -84,7 +84,12 @@ impl Command for List {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::List(tagname, filter, groups, window), ""))
|
||||
Ok(ListRequest {
|
||||
tagname,
|
||||
filter,
|
||||
groups,
|
||||
window,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Uri,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -23,7 +23,7 @@ impl Command for ListAll {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = parts
|
||||
.next()
|
||||
.map(|s| {
|
||||
@@ -34,7 +34,7 @@ impl Command for ListAll {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::ListAll(uri), ""))
|
||||
Ok(uri)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Uri,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -24,7 +24,7 @@ impl Command for ListAllInfo {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = parts
|
||||
.next()
|
||||
.map(|s| {
|
||||
@@ -35,7 +35,7 @@ impl Command for ListAllInfo {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::ListAllInfo(uri), ""))
|
||||
Ok(uri)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Uri,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -23,7 +23,7 @@ impl Command for ListFiles {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = parts
|
||||
.next()
|
||||
.map(|s| {
|
||||
@@ -34,7 +34,7 @@ impl Command for ListFiles {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::ListFiles(uri), ""))
|
||||
Ok(uri)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Uri,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
@@ -29,7 +29,7 @@ impl Command for LsInfo {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = parts
|
||||
.next()
|
||||
.map(|s| {
|
||||
@@ -40,7 +40,7 @@ impl Command for LsInfo {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::LsInfo(uri), ""))
|
||||
Ok(uri)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Uri,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{GenericResponseValue, ResponseAttributes},
|
||||
@@ -20,7 +20,7 @@ impl Command for ReadComments {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let uri = uri
|
||||
.parse()
|
||||
@@ -28,7 +28,7 @@ impl Command for ReadComments {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::ReadComments(uri), ""))
|
||||
Ok(uri)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{Offset, Uri},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{
|
||||
@@ -35,7 +35,7 @@ impl Command for ReadPicture {
|
||||
format!("{} {} {}", Self::COMMAND, request.uri, request.offset)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = match parts.next() {
|
||||
Some(s) => s,
|
||||
None => return Err(RequestParserError::UnexpectedEOF),
|
||||
@@ -50,7 +50,10 @@ impl Command for ReadPicture {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::ReadPicture(uri.to_string(), offset), ""))
|
||||
Ok(ReadPictureRequest {
|
||||
uri: uri.to_string(),
|
||||
offset,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Uri,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
||||
@@ -28,12 +28,12 @@ impl Command for Rescan {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = parts.next().map(|s| s.to_string());
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Rescan(uri), ""))
|
||||
Ok(uri)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{Sort, WindowRange},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -36,7 +36,7 @@ impl Command for Search {
|
||||
cmd
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let filter = match parts.next() {
|
||||
Some(f) => {
|
||||
Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))?
|
||||
@@ -66,7 +66,11 @@ impl Command for Search {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Search(filter, sort, window), ""))
|
||||
Ok(SearchRequest {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||
ResponseParserError,
|
||||
},
|
||||
commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError},
|
||||
common::types::{SongPosition, Sort, WindowRange},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -39,7 +36,7 @@ impl Command for SearchAdd {
|
||||
cmd
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let filter = match parts.next() {
|
||||
Some(f) => {
|
||||
Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))?
|
||||
@@ -79,7 +76,12 @@ impl Command for SearchAdd {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::SearchAdd(filter, sort, window, position), ""))
|
||||
Ok(SearchAddRequest {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
position,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, Request, RequestParserError, RequestParserResult, ResponseAttributes,
|
||||
ResponseParserError,
|
||||
},
|
||||
commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError},
|
||||
common::types::{PlaylistName, SongPosition, Sort, WindowRange},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -45,7 +42,7 @@ impl Command for SearchAddPl {
|
||||
cmd
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let playlist_name = parts
|
||||
.next()
|
||||
.ok_or(RequestParserError::UnexpectedEOF)?
|
||||
@@ -90,10 +87,13 @@ impl Command for SearchAddPl {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((
|
||||
Request::SearchAddPl(playlist_name, filter, sort, window, position),
|
||||
"",
|
||||
))
|
||||
Ok(SearchAddPlRequest {
|
||||
playlist_name,
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
position,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::GroupType,
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -37,7 +37,7 @@ impl Command for SearchCount {
|
||||
cmd
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let filter = match parts.next() {
|
||||
Some(f) => {
|
||||
Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))?
|
||||
@@ -58,7 +58,7 @@ impl Command for SearchCount {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::SearchCount(filter, group), ""))
|
||||
Ok(SearchCountRequest { filter, group })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Uri,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
||||
@@ -28,12 +28,12 @@ impl Command for Update {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = parts.next().map(|s| s.to_string());
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Update(uri), ""))
|
||||
Ok(uri)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::PartitionName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -16,7 +16,7 @@ impl Command for DelPartition {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let partition = parts
|
||||
.next()
|
||||
.ok_or(RequestParserError::UnexpectedEOF)?
|
||||
@@ -24,7 +24,7 @@ impl Command for DelPartition {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::DelPartition(partition), ""))
|
||||
Ok(partition)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::PartitionName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, expect_property_type},
|
||||
@@ -18,9 +18,9 @@ impl Command for ListPartitions {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::ListPartitions, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -15,7 +15,7 @@ impl Command for MoveOutput {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let output_name = parts
|
||||
.next()
|
||||
.ok_or(RequestParserError::UnexpectedEOF)?
|
||||
@@ -23,7 +23,7 @@ impl Command for MoveOutput {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::MoveOutput(output_name), ""))
|
||||
Ok(output_name)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::PartitionName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -16,7 +16,7 @@ impl Command for NewPartition {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let partition = parts
|
||||
.next()
|
||||
.ok_or(RequestParserError::UnexpectedEOF)?
|
||||
@@ -24,7 +24,7 @@ impl Command for NewPartition {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::NewPartition(partition), ""))
|
||||
Ok(partition)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::PartitionName,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -16,7 +16,7 @@ impl Command for Partition {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let partition = parts
|
||||
.next()
|
||||
.ok_or(RequestParserError::UnexpectedEOF)?
|
||||
@@ -24,7 +24,7 @@ impl Command for Partition {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Partition(partition), ""))
|
||||
Ok(partition)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::BoolOrOneshot,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -18,7 +18,7 @@ impl Command for Consume {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let state = match parts.next() {
|
||||
Some(s) => crate::common::types::BoolOrOneshot::from_str(s)
|
||||
.map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?,
|
||||
@@ -27,7 +27,7 @@ impl Command for Consume {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Consume(state), ""))
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Seconds,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -16,7 +16,7 @@ impl Command for Crossfade {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let seconds = match parts.next() {
|
||||
Some(s) => s
|
||||
.parse::<Seconds>()
|
||||
@@ -26,7 +26,7 @@ impl Command for Crossfade {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Crossfade(seconds), ""))
|
||||
Ok(seconds)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::VolumeValue,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
||||
@@ -18,9 +18,9 @@ impl Command for GetVol {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::GetVol, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -15,7 +15,7 @@ impl Command for MixRampDb {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let db = match parts.next() {
|
||||
Some(s) => s
|
||||
.parse::<f32>()
|
||||
@@ -25,7 +25,7 @@ impl Command for MixRampDb {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::MixRampDb(db), ""))
|
||||
Ok(db)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::Seconds,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -16,7 +16,7 @@ impl Command for MixRampDelay {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let seconds = match parts.next() {
|
||||
Some(s) => s
|
||||
.parse::<Seconds>()
|
||||
@@ -26,7 +26,7 @@ impl Command for MixRampDelay {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::MixRampDelay(seconds), ""))
|
||||
Ok(seconds)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -16,7 +16,7 @@ impl Command for Random {
|
||||
format!("{} {}", Self::COMMAND, state)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let state = match parts.next() {
|
||||
Some("0") => false,
|
||||
Some("1") => true,
|
||||
@@ -26,7 +26,7 @@ impl Command for Random {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Random(state), ""))
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -16,7 +16,7 @@ impl Command for Repeat {
|
||||
format!("{} {}", Self::COMMAND, state)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let state = match parts.next() {
|
||||
Some("0") => false,
|
||||
Some("1") => true,
|
||||
@@ -26,7 +26,7 @@ impl Command for Repeat {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Repeat(state), ""))
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::ReplayGainModeMode,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -18,7 +18,7 @@ impl Command for ReplayGainMode {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let mode = match parts.next() {
|
||||
Some(s) => ReplayGainModeMode::from_str(s)
|
||||
.map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?,
|
||||
@@ -27,7 +27,7 @@ impl Command for ReplayGainMode {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::ReplayGainMode(mode), ""))
|
||||
Ok(mode)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{collections::HashMap, str::FromStr};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::ReplayGainModeMode,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, get_property},
|
||||
@@ -25,9 +25,9 @@ impl Command for ReplayGainStatus {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::ReplayGainStatus, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::VolumeValue,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -18,7 +18,7 @@ impl Command for SetVol {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let volume = match parts.next() {
|
||||
Some(s) => VolumeValue::from_str(s)
|
||||
.map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?,
|
||||
@@ -27,7 +27,7 @@ impl Command for SetVol {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::SetVol(volume), ""))
|
||||
Ok(volume)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::BoolOrOneshot,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -18,7 +18,7 @@ impl Command for Single {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let state = match parts.next() {
|
||||
Some(s) => crate::common::types::BoolOrOneshot::from_str(s)
|
||||
.map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?,
|
||||
@@ -27,7 +27,7 @@ impl Command for Single {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Single(state), ""))
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::VolumeValue,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -18,7 +18,7 @@ impl Command for Volume {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let change = match parts.next() {
|
||||
Some(s) => VolumeValue::from_str(s)
|
||||
.map_err(|_| RequestParserError::SyntaxError(0, s.to_owned()))?,
|
||||
@@ -27,7 +27,7 @@ impl Command for Volume {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Volume(change), ""))
|
||||
Ok(change)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -16,10 +16,10 @@ impl Command for ClearError {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::ClearError, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -21,10 +21,10 @@ impl Command for CurrentSong {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::CurrentSong, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::SubSystem,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -30,16 +30,14 @@ impl Command for Idle {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
let result = parts
|
||||
.next()
|
||||
.map_or(Ok((Request::Idle(None), "")), |subsystems| {
|
||||
let subsystems = subsystems
|
||||
.split(',')
|
||||
.map(|subsystem| SubSystem::from_str(subsystem).unwrap())
|
||||
.collect();
|
||||
Ok((Request::Idle(Some(subsystems)), ""))
|
||||
});
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let result = parts.next().map_or(Ok(None), |subsystems| {
|
||||
let subsystems = subsystems
|
||||
.split(',')
|
||||
.map(|subsystem| SubSystem::from_str(subsystem).unwrap())
|
||||
.collect();
|
||||
Ok(Some(subsystems))
|
||||
});
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{
|
||||
ResponseAttributes, get_and_parse_optional_property, get_and_parse_property,
|
||||
@@ -32,10 +32,10 @@ impl Command for Stats {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Stats, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -4,12 +4,12 @@ use std::str::FromStr;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{Audio, BoolOrOneshot, SongId, SongPosition},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{
|
||||
GenericResponseValue, ResponseAttributes, get_and_parse_optional_property,
|
||||
get_and_parse_property, get_optional_property, get_property,
|
||||
ResponseAttributes, get_and_parse_optional_property, get_and_parse_property,
|
||||
get_optional_property, get_property,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -169,10 +169,10 @@ impl Command for Status {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Status, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{SongPosition, Uri},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -33,7 +33,7 @@ impl Command for Add {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = match parts.next() {
|
||||
Some(s) => s,
|
||||
None => return Err(RequestParserError::UnexpectedEOF),
|
||||
@@ -49,7 +49,10 @@ impl Command for Add {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Add(uri.to_string(), position), ""))
|
||||
Ok(AddRequest {
|
||||
uri: uri.to_string(),
|
||||
position,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{SongId, SongPosition, Uri},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::{ResponseAttributes, get_next_and_parse_property},
|
||||
@@ -32,7 +32,7 @@ impl Command for AddId {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let uri = match parts.next() {
|
||||
Some(s) => s,
|
||||
None => return Err(RequestParserError::UnexpectedEOF),
|
||||
@@ -48,7 +48,10 @@ impl Command for AddId {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::AddId(uri.to_string(), position), ""))
|
||||
Ok(AddIdRequest {
|
||||
uri: uri.to_string(),
|
||||
position,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{
|
||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||
},
|
||||
commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError},
|
||||
common::types::{SongId, TagName, TagValue},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
};
|
||||
@@ -33,7 +30,7 @@ impl Command for AddTagId {
|
||||
)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let songid = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let songid = songid
|
||||
.parse()
|
||||
@@ -51,7 +48,11 @@ impl Command for AddTagId {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::AddTagId(songid, tag_name, tag_value), ""))
|
||||
Ok(AddTagIdRequest {
|
||||
songid,
|
||||
tag_name,
|
||||
tag_value,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
commands::{Command, Request, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -15,9 +15,9 @@ impl Command for Clear {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::Clear, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{SongId, TagName},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -25,7 +24,7 @@ impl Command for ClearTagId {
|
||||
format!("{} {} {}", Self::COMMAND, request.songid, request.tag_name)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let songid = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let songid = songid
|
||||
.parse()
|
||||
@@ -38,7 +37,7 @@ impl Command for ClearTagId {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::ClearTagId(songid, tag_name), ""))
|
||||
Ok(ClearTagIdRequest { songid, tag_name })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::OneOrRange,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -19,14 +18,14 @@ impl Command for Delete {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let pos_or_range = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let one_or_range = OneOrRange::from_str(pos_or_range)
|
||||
.map_err(|_| RequestParserError::SyntaxError(0, pos_or_range.to_string()))?;
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Delete(one_or_range), ""))
|
||||
Ok(one_or_range)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::SongId,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -17,7 +16,7 @@ impl Command for DeleteId {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let id = id
|
||||
.parse()
|
||||
@@ -25,7 +24,7 @@ impl Command for DeleteId {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::DeleteId(id), ""))
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{
|
||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||
},
|
||||
commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError},
|
||||
common::types::{AbsouluteRelativeSongPosition, OneOrRange},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
};
|
||||
@@ -26,7 +23,7 @@ impl Command for Move {
|
||||
format!("{} {} {}", Self::COMMAND, request.from_or_range, request.to)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let from_or_range = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let from_or_range = from_or_range
|
||||
.parse()
|
||||
@@ -39,7 +36,7 @@ impl Command for Move {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Move(from_or_range, to), ""))
|
||||
Ok(MoveRequest { from_or_range, to })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{
|
||||
Command, RequestParserError, RequestParserResult, ResponseAttributes, ResponseParserError,
|
||||
},
|
||||
commands::{Command, RequestParserError, ResponseAttributes, ResponseParserError},
|
||||
common::types::{AbsouluteRelativeSongPosition, SongId},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
};
|
||||
@@ -26,7 +23,7 @@ impl Command for MoveId {
|
||||
format!("{} {} {}", Self::COMMAND, request.id, request.to)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let id = id
|
||||
.parse()
|
||||
@@ -39,7 +36,7 @@ impl Command for MoveId {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::MoveId(id, to), ""))
|
||||
Ok(MoveIdRequest { id, to })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
};
|
||||
@@ -16,9 +15,9 @@ impl Command for Playlist {
|
||||
Self::COMMAND.to_string()
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
debug_assert!(parts.next().is_none());
|
||||
Ok((Request::Playlist, ""))
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{Sort, WindowRange},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -34,7 +33,7 @@ impl Command for PlaylistFind {
|
||||
cmd
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let filter = match parts.next() {
|
||||
Some(f) => {
|
||||
Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))?
|
||||
@@ -64,7 +63,11 @@ impl Command for PlaylistFind {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::PlaylistFind(filter, sort, window), ""))
|
||||
Ok(PlaylistFindRequest {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::SongId,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -17,7 +16,7 @@ impl Command for PlaylistId {
|
||||
format!("{} {}", Self::COMMAND, request)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let id = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let id = id
|
||||
.parse()
|
||||
@@ -25,7 +24,7 @@ impl Command for PlaylistId {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::PlaylistId(id), ""))
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::OneOrRange,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -20,7 +19,7 @@ impl Command for PlaylistInfo {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let one_or_range = parts
|
||||
.next()
|
||||
.map(|s| {
|
||||
@@ -31,7 +30,7 @@ impl Command for PlaylistInfo {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::PlaylistInfo(one_or_range), ""))
|
||||
Ok(one_or_range)
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{Sort, WindowRange},
|
||||
filter::Filter,
|
||||
request_tokenizer::RequestTokenizer,
|
||||
@@ -34,7 +33,7 @@ impl Command for PlaylistSearch {
|
||||
cmd
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let filter = match parts.next() {
|
||||
Some(f) => {
|
||||
Filter::parse(f).map_err(|_| RequestParserError::SyntaxError(1, f.to_owned()))?
|
||||
@@ -64,7 +63,11 @@ impl Command for PlaylistSearch {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::PlaylistSearch(filter, sort, window), ""))
|
||||
Ok(PlaylistSearchRequest {
|
||||
filter,
|
||||
sort,
|
||||
window,
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{PlaylistVersion, WindowRange},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -28,7 +27,7 @@ impl Command for PlChanges {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let version = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let version = version
|
||||
.parse()
|
||||
@@ -44,7 +43,7 @@ impl Command for PlChanges {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::PlChanges(version, window), ""))
|
||||
Ok(PlChangesRequest { version, window })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{PlaylistVersion, WindowRange},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -28,7 +27,7 @@ impl Command for PlChangesPosId {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let version = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let version = version
|
||||
.parse()
|
||||
@@ -44,7 +43,7 @@ impl Command for PlChangesPosId {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::PlChangesPosId(version, window), ""))
|
||||
Ok(PlChangesPosIdRequest { version, window })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{Priority, WindowRange},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -25,7 +24,7 @@ impl Command for Prio {
|
||||
format!("{} {} {}", Self::COMMAND, request.prio, request.window)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let prio = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let prio = prio
|
||||
.parse()
|
||||
@@ -38,7 +37,7 @@ impl Command for Prio {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::Prio(prio, window), ""))
|
||||
Ok(PrioRequest { prio, window })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
Request,
|
||||
commands::{Command, RequestParserError, RequestParserResult, ResponseParserError},
|
||||
commands::{Command, RequestParserError, ResponseParserError},
|
||||
common::types::{Priority, SongId},
|
||||
request_tokenizer::RequestTokenizer,
|
||||
response_tokenizer::ResponseAttributes,
|
||||
@@ -31,7 +30,7 @@ impl Command for PrioId {
|
||||
format!("{} {} {}", Self::COMMAND, request.prio, songids)
|
||||
}
|
||||
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> RequestParserResult<'_> {
|
||||
fn parse_request(mut parts: RequestTokenizer<'_>) -> Result<Self::Request, RequestParserError> {
|
||||
let prio = parts.next().ok_or(RequestParserError::UnexpectedEOF)?;
|
||||
let prio = prio
|
||||
.parse()
|
||||
@@ -49,7 +48,7 @@ impl Command for PrioId {
|
||||
|
||||
debug_assert!(parts.next().is_none());
|
||||
|
||||
Ok((Request::PrioId(prio, songids), ""))
|
||||
Ok(PrioIdRequest { prio, songids })
|
||||
}
|
||||
|
||||
fn parse_response(
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user