pub struct EncodingBuffer { /* private fields */ }
Expand description
EncodingBuffer for a Mail providing a buffer for encodable traits.
Implementations§
Source§impl EncodingBuffer
impl EncodingBuffer
Sourcepub fn new(mail_type: MailType) -> Self
pub fn new(mail_type: MailType) -> Self
Create a new buffer only allowing input compatible with a the specified mail type.
Sourcepub fn writer(&mut self) -> EncodingWriter<'_>
pub fn writer(&mut self) -> EncodingWriter<'_>
returns a new EncodingWriter which contains a mutable reference to the current string buffer
Sourcepub fn write_header_line<FN>(&mut self, func: FN) -> Result<(), EncodingError>
pub fn write_header_line<FN>(&mut self, func: FN) -> Result<(), EncodingError>
calls the provided function with a EncodingWriter cleaning up afterwards
After calling func
with the EncodingWriter following cleanup is performed:
- if
func
returned an errorhandle.undo_header()
is called, this won’t undo anything before afinish_header()
call but will discard partial writes - if
func
succeededhandle.finish_header()
is called
pub fn write_blank_line(&mut self)
Sourcepub fn write_body_unchecked(&mut self, body: &impl AsRef<[u8]>)
pub fn write_body_unchecked(&mut self, body: &impl AsRef<[u8]>)
writes a body to the internal buffer, without verifying it’s correctness
Sourcepub fn as_str(&self) -> Result<&str, EncodingError>
pub fn as_str(&self) -> Result<&str, EncodingError>
§Error
This can fail if a body does not contain valid utf8.
Sourcepub fn to_string(&self) -> Result<String, EncodingError>
pub fn to_string(&self) -> Result<String, EncodingError>
Converts the internal buffer into an utf-8 string if possible.
Sourcepub fn to_string_lossy(&self) -> Cow<'_, str>
pub fn to_string_lossy(&self) -> Cow<'_, str>
Lossy conversion of the internal buffer to an string.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EncodingBuffer
impl RefUnwindSafe for EncodingBuffer
impl Send for EncodingBuffer
impl Sync for EncodingBuffer
impl Unpin for EncodingBuffer
impl UnwindSafe for EncodingBuffer
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