pub struct Writer { /* private fields */ }Expand description
Appends canonical encodings to a buffer. Variable fields take their limit and fail above it,
mirroring super::Reader.
Implementations§
Source§impl Writer
impl Writer
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
The encoding so far.
Sourcepub fn string(&mut self, text: &str, max: usize) -> Result<(), EncodeError>
pub fn string(&mut self, text: &str, max: usize) -> Result<(), EncodeError>
string: u32 byte length, then UTF-8. max is in bytes.
§Errors
EncodeError::OverLimit when longer than max bytes.
Sourcepub fn option<T>(
&mut self,
value: Option<&T>,
f: impl FnOnce(&mut Self, &T) -> Result<(), EncodeError>,
) -> Result<(), EncodeError>
pub fn option<T>( &mut self, value: Option<&T>, f: impl FnOnce(&mut Self, &T) -> Result<(), EncodeError>, ) -> Result<(), EncodeError>
Sourcepub fn list<T>(
&mut self,
items: &[T],
max: usize,
f: impl FnMut(&mut Self, &T) -> Result<(), EncodeError>,
) -> Result<(), EncodeError>
pub fn list<T>( &mut self, items: &[T], max: usize, f: impl FnMut(&mut Self, &T) -> Result<(), EncodeError>, ) -> Result<(), EncodeError>
list<T>: u32 count, then each element written by f.
§Errors
EncodeError::OverLimit when more than max elements, or whatever f returns.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Writer
impl RefUnwindSafe for Writer
impl Send for Writer
impl Sync for Writer
impl Unpin for Writer
impl UnsafeUnpin for Writer
impl UnwindSafe for Writer
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