pub struct Attachment {
pub filename: String,
pub content_type: String,
pub content: Vec<u8>,
pub content_id: Option<String>,
pub disposition: AttachmentDisposition,
pub size: usize,
pub compressed: bool,
}Expand description
Email attachment
Fields§
§filename: StringFilename
content_type: StringMIME content type
content: Vec<u8>Binary content
content_id: Option<String>Inline attachment ID for embedding in HTML
disposition: AttachmentDispositionAttachment disposition (attachment or inline)
size: usizeAttachment size in bytes
compressed: boolWhether content is compressed
Implementations§
Source§impl Attachment
impl Attachment
Sourcepub fn new(filename: impl Into<String>, content: Vec<u8>) -> Self
pub fn new(filename: impl Into<String>, content: Vec<u8>) -> Self
Create a new attachment with automatic MIME type detection
Sourcepub fn inline(
filename: impl Into<String>,
content: Vec<u8>,
content_id: impl Into<String>,
) -> Self
pub fn inline( filename: impl Into<String>, content: Vec<u8>, content_id: impl Into<String>, ) -> Self
Create a new inline attachment (for embedding in HTML)
Sourcepub fn with_content_type(self, content_type: impl Into<String>) -> Self
pub fn with_content_type(self, content_type: impl Into<String>) -> Self
Set custom content type
Sourcepub fn can_compress(&self) -> bool
pub fn can_compress(&self) -> bool
Check if attachment can be compressed
Sourcepub fn validate(&self, config: &AttachmentConfig) -> Result<(), EmailError>
pub fn validate(&self, config: &AttachmentConfig) -> Result<(), EmailError>
Validate attachment against configuration
Trait Implementations§
Source§impl Clone for Attachment
impl Clone for Attachment
Source§fn clone(&self) -> Attachment
fn clone(&self) -> Attachment
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Attachment
impl Debug for Attachment
Source§impl<'de> Deserialize<'de> for Attachment
impl<'de> Deserialize<'de> for Attachment
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Attachment
impl RefUnwindSafe for Attachment
impl Send for Attachment
impl Sync for Attachment
impl Unpin for Attachment
impl UnwindSafe for Attachment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more