pub struct MediaAttachment {
pub file_name: String,
pub data: Vec<u8>,
pub mime_type: Option<String>,
}Expand description
A single media attachment on an inbound message.
Fields§
§file_name: StringOriginal file name (e.g. voice.ogg, photo.jpg).
data: Vec<u8>Raw bytes of the attachment.
mime_type: Option<String>MIME type if known (e.g. audio/ogg, image/jpeg).
Implementations§
Source§impl MediaAttachment
impl MediaAttachment
Sourcepub fn from_file(path: &str) -> Result<Self>
pub fn from_file(path: &str) -> Result<Self>
Load an attachment from a file path on disk.
§Caller path-validation contract
This method reads the path supplied by the caller verbatim. Callers
are responsible for validating or constraining path before calling
this function when the path originates from untrusted input (e.g. a
user message, an HTTP request body, or any external data source). No
sandboxing or path canonicalization is performed here.
Read errors are propagated as Err rather than silently producing an
empty attachment, so the caller can decide how to handle missing or
unreadable files.
Trait Implementations§
Source§impl Clone for MediaAttachment
impl Clone for MediaAttachment
Source§fn clone(&self) -> MediaAttachment
fn clone(&self) -> MediaAttachment
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 moreAuto Trait Implementations§
impl Freeze for MediaAttachment
impl RefUnwindSafe for MediaAttachment
impl Send for MediaAttachment
impl Sync for MediaAttachment
impl Unpin for MediaAttachment
impl UnsafeUnpin for MediaAttachment
impl UnwindSafe for MediaAttachment
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