pub struct Encoder<B> { /* private fields */ }
Expand description
An Encoder
wraps any value implementing MutableBuffer
and writes diagnostic stream records
into it.
Implementations§
Source§impl<B> Encoder<B>where
B: MutableBuffer,
impl<B> Encoder<B>where
B: MutableBuffer,
Sourcepub fn new(buf: B, options: EncoderOpts) -> Self
pub fn new(buf: B, options: EncoderOpts) -> Self
Create a new Encoder
from the provided buffer.
Sourcepub fn inner(&self) -> &B
pub fn inner(&self) -> &B
Returns a reference to the underlying buffer being used for encoding.
Sourcepub fn write_event<'a, E, MS, T>(
&mut self,
params: WriteEventParams<'a, E, T, MS>,
) -> Result<(), EncodingError>
pub fn write_event<'a, E, MS, T>( &mut self, params: WriteEventParams<'a, E, T, MS>, ) -> Result<(), EncodingError>
Writes an event to to the buffer as a record.
Fails if there is insufficient space in the buffer for encoding.
Sourcepub fn write_record<R>(&mut self, record: R) -> Result<(), EncodingError>where
R: RecordFields,
pub fn write_record<R>(&mut self, record: R) -> Result<(), EncodingError>where
R: RecordFields,
Writes a Record to the buffer.
Sourcepub fn write_raw_argument(
&mut self,
name: &str,
value: impl WriteArgumentValue<B>,
) -> Result<(), EncodingError>
pub fn write_raw_argument( &mut self, name: &str, value: impl WriteArgumentValue<B>, ) -> Result<(), EncodingError>
Writes an argument with this encoder with the given name and value.
Sourcepub fn write_argument<'a>(
&mut self,
argument: impl Borrow<Argument<'a>>,
) -> Result<(), EncodingError>
pub fn write_argument<'a>( &mut self, argument: impl Borrow<Argument<'a>>, ) -> Result<(), EncodingError>
Writes an argument with this encoder.
Auto Trait Implementations§
impl<B> Freeze for Encoder<B>where
B: Freeze,
impl<B> RefUnwindSafe for Encoder<B>where
B: RefUnwindSafe,
impl<B> Send for Encoder<B>where
B: Send,
impl<B> Sync for Encoder<B>where
B: Sync,
impl<B> Unpin for Encoder<B>where
B: Unpin,
impl<B> UnwindSafe for Encoder<B>where
B: UnwindSafe,
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