eml-codec/src/part/discrete.rs

40 lines
978 B
Rust
Raw Normal View History

2023-07-24 10:26:53 +00:00
use std::fmt;
use crate::mime;
#[derive(PartialEq)]
pub struct Text<'a> {
2023-07-25 12:00:01 +00:00
pub mime: mime::MIME<'a, mime::r#type::DeductibleText>,
2023-07-24 10:37:30 +00:00
pub body: &'a [u8],
2023-07-24 10:26:53 +00:00
}
impl<'a> fmt::Debug for Text<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2023-07-24 10:37:30 +00:00
fmt.debug_struct("part::Text")
2023-07-25 12:00:01 +00:00
.field("mime", &self.mime)
2023-07-24 10:37:30 +00:00
.field(
"body",
&format_args!("\"{}\"", String::from_utf8_lossy(self.body)),
)
2023-07-24 10:26:53 +00:00
.finish()
}
}
#[derive(PartialEq)]
pub struct Binary<'a> {
2023-07-25 12:00:01 +00:00
pub mime: mime::MIME<'a, mime::r#type::Binary>,
2023-07-24 10:37:30 +00:00
pub body: &'a [u8],
2023-07-24 10:26:53 +00:00
}
impl<'a> fmt::Debug for Binary<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2023-07-24 10:37:30 +00:00
fmt.debug_struct("part::Binary")
2023-07-25 12:00:01 +00:00
.field("mime", &self.mime)
2023-07-24 10:37:30 +00:00
.field(
"body",
&format_args!("\"{}\"", String::from_utf8_lossy(self.body)),
)
2023-07-24 10:26:53 +00:00
.finish()
}
}