apply clippy

This commit is contained in:
yggverse 2025-03-24 07:10:22 +02:00
parent 0717e473b7
commit 68e7894125
3 changed files with 9 additions and 5 deletions

View file

@ -16,10 +16,10 @@ impl Success {
/// Parse new `Self` from buffer bytes
pub fn parse(buffer: &[u8]) -> Result<Self, Error> {
if !buffer.first().is_some_and(|b| *b == CODE) {
if buffer.first().is_none_or(|b| *b != CODE) {
return Err(Error::Code);
}
match Default::parse(&buffer) {
match Default::parse(buffer) {
Ok(default) => Ok(Self::Default(default)),
Err(e) => Err(Error::Default(e)),
}

View file

@ -18,7 +18,7 @@ impl Default {
if !buffer.starts_with(CODE) {
return Err(Error::Code);
}
let header = Header::parse(buffer).map_err(|e| Error::Header(e))?;
let header = Header::parse(buffer).map_err(Error::Header)?;
Ok(Self {
content: buffer.get(header.len() + 1..).map(|v| v.to_vec()),
header,

View file

@ -12,7 +12,7 @@ impl Header {
}
Ok(Self(
crate::client::connection::response::header_bytes(buffer)
.map_err(|e| Error::Header(e))?
.map_err(Error::Header)?
.to_vec(),
))
}
@ -23,7 +23,7 @@ impl Header {
pub fn mime(&self) -> Result<String, Error> {
glib::Regex::split_simple(
r"^\d{2}\s([^\/]+\/[^\s;]+)",
std::str::from_utf8(&self.0).map_err(|e| Error::Utf8Error(e))?,
std::str::from_utf8(&self.0).map_err(Error::Utf8Error)?,
glib::RegexCompileFlags::DEFAULT,
glib::RegexMatchFlags::DEFAULT,
)
@ -37,6 +37,10 @@ impl Header {
self.0.len()
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
pub fn as_bytes(&self) -> &[u8] {
&self.0
}