pub struct Encoder<W> { /* private fields */ }
Expand description
A non-allocating CBOR encoder writing encoded bytes to the given Write
sink.
Implementations§
Source§impl<W: Write> Encoder<W>
impl<W: Write> Encoder<W>
Sourcepub fn writer_mut(&mut self) -> &mut W
pub fn writer_mut(&mut self) -> &mut W
Get mutable access to the inner writer.
Sourcepub fn into_writer(self) -> W
pub fn into_writer(self) -> W
Get back the Write
impl.
Sourcepub fn encode<T: Encode<()>>(
&mut self,
x: T,
) -> Result<&mut Self, Error<W::Error>>
pub fn encode<T: Encode<()>>( &mut self, x: T, ) -> Result<&mut Self, Error<W::Error>>
Encode any type that implements Encode
.
Sourcepub fn encode_with<C, T: Encode<C>>(
&mut self,
x: T,
ctx: &mut C,
) -> Result<&mut Self, Error<W::Error>>
pub fn encode_with<C, T: Encode<C>>( &mut self, x: T, ctx: &mut C, ) -> Result<&mut Self, Error<W::Error>>
Encode any type that implements Encode
.
Sourcepub fn int(&mut self, x: Int) -> Result<&mut Self, Error<W::Error>>
pub fn int(&mut self, x: Int) -> Result<&mut Self, Error<W::Error>>
Encode a CBOR integer.
See Int
for details regarding the value range of CBOR integers.
Sourcepub fn undefined(&mut self) -> Result<&mut Self, Error<W::Error>>
pub fn undefined(&mut self) -> Result<&mut Self, Error<W::Error>>
Encode a CBOR undefined
value.
Sourcepub fn simple(&mut self, x: u8) -> Result<&mut Self, Error<W::Error>>
pub fn simple(&mut self, x: u8) -> Result<&mut Self, Error<W::Error>>
Encode a CBOR simple value.
Sourcepub fn tag<T: Into<Tag>>(&mut self, x: T) -> Result<&mut Self, Error<W::Error>>
pub fn tag<T: Into<Tag>>(&mut self, x: T) -> Result<&mut Self, Error<W::Error>>
Encode a CBOR tag.
Sourcepub fn array(&mut self, len: u64) -> Result<&mut Self, Error<W::Error>>
pub fn array(&mut self, len: u64) -> Result<&mut Self, Error<W::Error>>
Begin encoding an array with len
elements.
Sourcepub fn map(&mut self, len: u64) -> Result<&mut Self, Error<W::Error>>
pub fn map(&mut self, len: u64) -> Result<&mut Self, Error<W::Error>>
Begin encoding a map with len
entries.
Sourcepub fn begin_array(&mut self) -> Result<&mut Self, Error<W::Error>>
pub fn begin_array(&mut self) -> Result<&mut Self, Error<W::Error>>
Begin encoding an array of unknown size.
Use Encoder::end
to terminate the array.
Sourcepub fn begin_bytes(&mut self) -> Result<&mut Self, Error<W::Error>>
pub fn begin_bytes(&mut self) -> Result<&mut Self, Error<W::Error>>
Begin encoding an indefinite number of byte slices.
Use Encoder::end
to terminate.
Sourcepub fn begin_map(&mut self) -> Result<&mut Self, Error<W::Error>>
pub fn begin_map(&mut self) -> Result<&mut Self, Error<W::Error>>
Begin encoding a map of unknown size.
Use Encoder::end
to terminate the map.
Sourcepub fn begin_str(&mut self) -> Result<&mut Self, Error<W::Error>>
pub fn begin_str(&mut self) -> Result<&mut Self, Error<W::Error>>
Begin encoding an indefinite number of string slices.
Use Encoder::end
to terminate.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.