cargo fmt + clippy
This commit is contained in:
@@ -51,7 +51,7 @@ where
|
||||
.await
|
||||
.map_err(MpdClientError::ConnectionError)?;
|
||||
|
||||
return Ok(version_line.trim().to_string());
|
||||
Ok(version_line.trim().to_string())
|
||||
}
|
||||
|
||||
async fn read_response(&mut self) -> Result<Vec<u8>, MpdClientError> {
|
||||
|
||||
@@ -179,45 +179,45 @@ pub trait Command {
|
||||
Self: Sized,
|
||||
T: AsyncWrite + AsyncRead + Unpin,
|
||||
{
|
||||
let payload = request.serialize();
|
||||
let payload = request.serialize();
|
||||
|
||||
connection
|
||||
.write_all(payload.as_bytes())
|
||||
.await
|
||||
.map_err(crate::MpdClientError::ConnectionError)?;
|
||||
connection
|
||||
.write_all(payload.as_bytes())
|
||||
.await
|
||||
.map_err(crate::MpdClientError::ConnectionError)?;
|
||||
|
||||
connection
|
||||
.flush()
|
||||
.await
|
||||
.map_err(crate::MpdClientError::ConnectionError)?;
|
||||
connection
|
||||
.flush()
|
||||
.await
|
||||
.map_err(crate::MpdClientError::ConnectionError)?;
|
||||
|
||||
let mut response_bytes = Vec::new();
|
||||
let mut reader = BufReader::new(connection);
|
||||
let mut response_bytes = Vec::new();
|
||||
let mut reader = BufReader::new(connection);
|
||||
|
||||
loop {
|
||||
let mut line = Vec::new();
|
||||
loop {
|
||||
let mut line = Vec::new();
|
||||
|
||||
let bytes_read = reader
|
||||
.read_until(b'\n', &mut line)
|
||||
.await
|
||||
.map_err(crate::MpdClientError::ConnectionError)?;
|
||||
let bytes_read = reader
|
||||
.read_until(b'\n', &mut line)
|
||||
.await
|
||||
.map_err(crate::MpdClientError::ConnectionError)?;
|
||||
|
||||
if bytes_read == 0 {
|
||||
break; // EOF reached
|
||||
}
|
||||
if bytes_read == 0 {
|
||||
break; // EOF reached
|
||||
}
|
||||
|
||||
response_bytes.extend_from_slice(&line);
|
||||
response_bytes.extend_from_slice(&line);
|
||||
|
||||
// TODO: handle errors properly
|
||||
if line == b"OK\n" || line.starts_with(b"ACK ") {
|
||||
break; // End of response
|
||||
}
|
||||
}
|
||||
// TODO: handle errors properly
|
||||
if line == b"OK\n" || line.starts_with(b"ACK ") {
|
||||
break; // End of response
|
||||
}
|
||||
}
|
||||
|
||||
let response = Self::parse_raw_response(&response_bytes)
|
||||
.map_err(crate::MpdClientError::ResponseParseError)?;
|
||||
let response = Self::parse_raw_response(&response_bytes)
|
||||
.map_err(crate::MpdClientError::ResponseParseError)?;
|
||||
|
||||
Ok(response)
|
||||
Ok(response)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,7 +505,6 @@ pub enum RequestParserError {
|
||||
|
||||
#[error("Request ended early, while more arguments were expected")]
|
||||
UnexpectedEOF,
|
||||
|
||||
// #[error("Request is missing terminating newline")]
|
||||
// MissingNewline,
|
||||
}
|
||||
@@ -537,7 +536,6 @@ pub enum ResponseParserError {
|
||||
|
||||
#[error("Response ended early, while more properties were expected")]
|
||||
UnexpectedEOF,
|
||||
|
||||
// #[error("Response is missing terminating newline")]
|
||||
// MissingNewline,
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError,
|
||||
single_optional_item_command_request,
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSelectionPrintResponse, Uri},
|
||||
|
||||
@@ -2,8 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError,
|
||||
single_optional_item_command_request,
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSelectionPrintResponse, Uri},
|
||||
|
||||
@@ -2,8 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError,
|
||||
single_optional_item_command_request,
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbDirectoryInfo, DbSelectionPrintResponse, Uri},
|
||||
|
||||
@@ -2,8 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError,
|
||||
single_optional_item_command_request,
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSelectionPrintResponse, Uri},
|
||||
|
||||
@@ -4,8 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError,
|
||||
single_optional_item_command_request,
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
||||
types::Uri,
|
||||
|
||||
@@ -4,8 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError,
|
||||
single_optional_item_command_request,
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
response_tokenizer::{ResponseAttributes, get_and_parse_property},
|
||||
types::Uri,
|
||||
|
||||
@@ -2,8 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, CommandResponse, ResponseParserError,
|
||||
single_optional_item_command_request,
|
||||
Command, CommandResponse, ResponseParserError, single_optional_item_command_request,
|
||||
},
|
||||
response_tokenizer::ResponseAttributes,
|
||||
types::{DbSongInfo, OneOrRange, Priority, SongId, SongPosition},
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
use crate::{
|
||||
commands::{
|
||||
Command, empty_command_response, single_optional_item_command_request,
|
||||
},
|
||||
commands::{Command, empty_command_response, single_optional_item_command_request},
|
||||
types::OneOrRange,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user