mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 09:05:45 +00:00
apply clippy
This commit is contained in:
parent
0717e473b7
commit
68e7894125
3 changed files with 9 additions and 5 deletions
|
|
@ -16,10 +16,10 @@ impl Success {
|
||||||
|
|
||||||
/// Parse new `Self` from buffer bytes
|
/// Parse new `Self` from buffer bytes
|
||||||
pub fn parse(buffer: &[u8]) -> Result<Self, Error> {
|
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);
|
return Err(Error::Code);
|
||||||
}
|
}
|
||||||
match Default::parse(&buffer) {
|
match Default::parse(buffer) {
|
||||||
Ok(default) => Ok(Self::Default(default)),
|
Ok(default) => Ok(Self::Default(default)),
|
||||||
Err(e) => Err(Error::Default(e)),
|
Err(e) => Err(Error::Default(e)),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ impl Default {
|
||||||
if !buffer.starts_with(CODE) {
|
if !buffer.starts_with(CODE) {
|
||||||
return Err(Error::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 {
|
Ok(Self {
|
||||||
content: buffer.get(header.len() + 1..).map(|v| v.to_vec()),
|
content: buffer.get(header.len() + 1..).map(|v| v.to_vec()),
|
||||||
header,
|
header,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ impl Header {
|
||||||
}
|
}
|
||||||
Ok(Self(
|
Ok(Self(
|
||||||
crate::client::connection::response::header_bytes(buffer)
|
crate::client::connection::response::header_bytes(buffer)
|
||||||
.map_err(|e| Error::Header(e))?
|
.map_err(Error::Header)?
|
||||||
.to_vec(),
|
.to_vec(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
@ -23,7 +23,7 @@ impl Header {
|
||||||
pub fn mime(&self) -> Result<String, Error> {
|
pub fn mime(&self) -> Result<String, Error> {
|
||||||
glib::Regex::split_simple(
|
glib::Regex::split_simple(
|
||||||
r"^\d{2}\s([^\/]+\/[^\s;]+)",
|
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::RegexCompileFlags::DEFAULT,
|
||||||
glib::RegexMatchFlags::DEFAULT,
|
glib::RegexMatchFlags::DEFAULT,
|
||||||
)
|
)
|
||||||
|
|
@ -37,6 +37,10 @@ impl Header {
|
||||||
self.0.len()
|
self.0.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.0.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn as_bytes(&self) -> &[u8] {
|
pub fn as_bytes(&self) -> &[u8] {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue