pub struct Encoder<W> { /* private fields */ }
Expand description
A non-allocating CBOR encoder writing encoded bytes to the given Write
sink.
Implementations
sourceimpl<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> 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more