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 into_inner(self) -> W
pub fn into_inner(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 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 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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)