Struct Writer
pub struct Writer { /* private fields */ }Expand description
A buffer values are written to. Reuse one to keep the allocation.
Implementations§
§impl Writer
impl Writer
pub fn clear(&mut self)
pub fn clear(&mut self)
Empties it, keeping its allocation and resetting any per-call error and byte limit.
pub fn replace(&mut self, buffer: Vec<u8>)
pub fn replace(&mut self, buffer: Vec<u8>)
Takes buffer as its storage, emptied, resetting the error and byte limit.
pub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
The bytes written, leaving the writer’s storage to the caller.
pub fn limit(&mut self, max_bytes: usize)
pub fn limit(&mut self, max_bytes: usize)
Bound this call’s encoded bytes. A refusal is recorded before any growth or copy.
A new writer has no limit; clear and replace remove it.
pub fn put_opt<T>(&mut self, value: Option<&T>)
pub fn put_opt<T>(&mut self, value: Option<&T>)
An optional borrowed value, written as the Option it stands for.
pub fn put_owned<T>(&mut self, value: T)where
T: Wire,
pub fn put_owned<T>(&mut self, value: T)where
T: Wire,
Transfers owned resources while leaving plain data on the normal zero-copy path.
pub fn nested(&mut self, write: impl FnOnce(&mut Writer))
pub fn nested(&mut self, write: impl FnOnce(&mut Writer))
Writes one structural level, refusing before recursing past MAX_DEPTH.
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