store MIME value in lowercase presentation

This commit is contained in:
yggverse 2025-01-18 02:18:56 +02:00
parent d3133f50f7
commit e456719e58

View file

@ -29,7 +29,7 @@ impl Mime {
// Parse meta bytes only // Parse meta bytes only
match buffer.get(..if len > MAX_LEN { MAX_LEN } else { len }) { match buffer.get(..if len > MAX_LEN { MAX_LEN } else { len }) {
Some(value) => match GString::from_utf8(value.into()) { Some(value) => match GString::from_utf8(value.into()) {
Ok(string) => Self::from_string(string.as_str()), Ok(string) => Self::from_string(&string),
Err(e) => Err(Error::Decode(e)), Err(e) => Err(Error::Decode(e)),
}, },
None => Err(Error::Protocol), None => Err(Error::Protocol),
@ -43,16 +43,16 @@ impl Mime {
return Ok(None); return Ok(None);
} }
match parse(subject) { match parse(subject) {
Some(value) => Ok(Some(Self(value))), Some(value) => Ok(Some(Self(value.to_lowercase()))),
None => Err(Error::Undefined), None => Err(Error::Undefined),
} }
} }
// Getters // Getters
/// Get `Self` as `&str` /// Get `Self` as lowercase `std::str`
pub fn as_str(&self) -> &str { pub fn as_str(&self) -> &str {
&self.0 self.0.as_str()
} }
} }