pub struct MailAttachment {
pub filename: String,
pub content: Vec<u8>,
pub mime_type: String,
}Expand description
邮件附件
对齐 PHP think\mail\Attachment。
Fields§
§filename: String附件文件名
content: Vec<u8>附件内容(字节)
mime_type: StringMIME 类型(如 application/pdf)
Implementations§
Source§impl MailAttachment
impl MailAttachment
Sourcepub fn new(
filename: impl Into<String>,
content: Vec<u8>,
mime_type: impl Into<String>,
) -> MailAttachment
pub fn new( filename: impl Into<String>, content: Vec<u8>, mime_type: impl Into<String>, ) -> MailAttachment
Sourcepub async fn from_file(
path: impl AsRef<Path>,
filename: Option<&str>,
mime_type: impl Into<String>,
) -> Result<MailAttachment, MailError>
pub async fn from_file( path: impl AsRef<Path>, filename: Option<&str>, mime_type: impl Into<String>, ) -> Result<MailAttachment, MailError>
从文件路径创建附件
§参数
path: 文件路径filename: 指定文件名(None时使用路径中的文件名)mime_type: MIME 类型
§返回
成功返回 MailAttachment,失败返回 MailError::AttachmentRead。
Trait Implementations§
Source§impl Clone for MailAttachment
impl Clone for MailAttachment
Source§fn clone(&self) -> MailAttachment
fn clone(&self) -> MailAttachment
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 MailAttachment
impl RefUnwindSafe for MailAttachment
impl Send for MailAttachment
impl Sync for MailAttachment
impl Unpin for MailAttachment
impl UnsafeUnpin for MailAttachment
impl UnwindSafe for MailAttachment
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.