[][src]Struct mail_internals::encoder::EncodingBuffer

pub struct EncodingBuffer { /* fields omitted */ }

EncodingBuffer for a Mail providing a buffer for encodable traits.

Methods

impl EncodingBuffer[src]

pub fn new(mail_type: MailType) -> Self[src]

Create a new buffer only allowing input compatible with a the specified mail type.

pub fn mail_type(&self) -> MailType[src]

Returns the mail type for which the buffer was created.

pub fn writer(&mut self) -> EncodingWriter[src]

returns a new EncodingWriter which contains a mutable reference to the current string buffer

pub fn write_header_line<FN>(&mut self, func: FN) -> Result<(), EncodingError> where
    FN: FnOnce(&mut EncodingWriter) -> Result<(), EncodingError>, 
[src]

calls the provided function with a EncodingWriter cleaning up afterwards

After calling func with the EncodingWriter following cleanup is performed:

  • if func returned an error handle.undo_header() is called, this won't undo anything before a finish_header() call but will discard partial writes
  • if func succeeded handle.finish_header() is called

pub fn write_blank_line(&mut self)[src]

pub fn write_body_unchecked(&mut self, body: &impl AsRef<[u8]>)[src]

writes a body to the internal buffer, without verifying it's correctness

pub fn as_str(&self) -> Result<&str, EncodingError>[src]

Error

This can fail if a body does not contain valid utf8.

pub fn to_string(&self) -> Result<String, EncodingError>[src]

Converts the internal buffer into an utf-8 string if possible.

pub fn to_string_lossy(&self) -> Cow<str>[src]

Lossy conversion of the internal buffer to an string.

pub fn as_slice(&self) -> &[u8][src]

Return a slice view to the underlying buffer.

Trait Implementations

impl Into<Vec<u8>> for EncodingBuffer[src]

impl Into<(MailType, Vec<u8>)> for EncodingBuffer[src]

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]