cargo fmt + clippy
Some checks failed
Build and test / build (push) Failing after 1m5s
Build and test / check (push) Failing after 1m17s
Build and test / test (push) Failing after 1m21s
Build and test / docs (push) Failing after 1m13s

This commit is contained in:
2025-12-08 13:28:45 +09:00
parent 7ce0d68021
commit a7a8ceedeb
10 changed files with 38 additions and 49 deletions

View File

@@ -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> {

View File

@@ -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,
}

View File

@@ -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},

View File

@@ -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},

View File

@@ -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},

View File

@@ -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},

View File

@@ -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,

View File

@@ -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,

View File

@@ -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},

View File

@@ -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,
};