pub struct Encoder<W: Write>(/* private fields */);
Expand description
An encoder for serializing CBOR items
This structure wraps a writer and provides convenience functions for
writing Header
objects to the wire.
Implementations§
Source§impl<W: Write> Encoder<W>
impl<W: Write> Encoder<W>
Sourcepub fn bytes(
&mut self,
value: &[u8],
segment: impl Into<Option<usize>>,
) -> Result<(), W::Error>
pub fn bytes( &mut self, value: &[u8], segment: impl Into<Option<usize>>, ) -> Result<(), W::Error>
Serialize a byte slice as CBOR
Optionally, segment the output into segment
size segments. Note that
if segment == Some(0)
it will be silently upgraded to Some(1)
. This
minimum value is highly inefficient and should not be relied upon.
Sourcepub fn text(
&mut self,
value: &str,
segment: impl Into<Option<usize>>,
) -> Result<(), W::Error>
pub fn text( &mut self, value: &str, segment: impl Into<Option<usize>>, ) -> Result<(), W::Error>
Serialize a string slice as CBOR
Optionally, segment the output into segment
size segments. Note that
since care is taken to ensure that each segment is itself a valid UTF-8
string, if segment
contains a value of less than 4, it will be
silently upgraded to 4. This minimum value is highly inefficient and
should not be relied upon.
Trait Implementations§
Auto Trait Implementations§
impl<W> Freeze for Encoder<W>where
W: Freeze,
impl<W> RefUnwindSafe for Encoder<W>where
W: RefUnwindSafe,
impl<W> Send for Encoder<W>where
W: Send,
impl<W> Sync for Encoder<W>where
W: Sync,
impl<W> Unpin for Encoder<W>where
W: Unpin,
impl<W> UnwindSafe for Encoder<W>where
W: 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
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.