pub struct Body { /* private fields */ }Expand description
A Message or SinglePart body that has already been encoded.
Implementations§
Source§impl Body
impl Body
Sourcepub fn new<B: Into<MaybeString>>(buf: B) -> Self
pub fn new<B: Into<MaybeString>>(buf: B) -> Self
Encode the supplied buf, making it ready to be sent as a body.
Takes a Vec<u8> or a String.
Automatically chooses the most efficient encoding between
7bit, quoted-printable and base64.
If String is passed, line endings are converted to CRLF.
If buf is valid utf-8 a String should be supplied, as Strings
can be encoded as 7bit or quoted-printable, while Vec<u8> always
get encoded as base64.
Sourcepub fn new_with_encoding<B: Into<MaybeString>>(
buf: B,
encoding: ContentTransferEncoding,
) -> Result<Self, Vec<u8>>
pub fn new_with_encoding<B: Into<MaybeString>>( buf: B, encoding: ContentTransferEncoding, ) -> Result<Self, Vec<u8>>
Sourcepub fn dangerous_pre_encoded(
buf: Vec<u8>,
encoding: ContentTransferEncoding,
) -> Self
pub fn dangerous_pre_encoded( buf: Vec<u8>, encoding: ContentTransferEncoding, ) -> Self
Builds a new Body using a pre-encoded buffer.
Generally not you want.
buf shouldn’t contain non-ascii characters, lines longer than 1000 characters or nul bytes.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if this Body has a length of zero, false otherwise.
Sourcepub fn encoding(&self) -> ContentTransferEncoding
pub fn encoding(&self) -> ContentTransferEncoding
Returns the Content-Transfer-Encoding of this Body.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Body
impl RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnwindSafe for Body
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