pub struct MapEncodeBuffer {
pub data: Vec<u8>,
pub entries: Vec<(i64, usize, usize)>,
}Available on crate feature
cbor only.Expand description
A collector of CBOR map entries in a single shared buffer,
recording (key, start, end) offsets. This avoids per-field allocation:
all encoded values are written contiguously into data.
Fields§
§data: Vec<u8>Encoded values, written back to back.
entries: Vec<(i64, usize, usize)>Key and the value’s byte range within data, one per entry.
Implementations§
Source§impl MapEncodeBuffer
impl MapEncodeBuffer
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Creates a new buffer pre-sized for the expected number of entries.
Sourcepub fn push<T: Encode>(&mut self, key: i64, value: &T) -> Result<(), Error>
pub fn push<T: Encode>(&mut self, key: i64, value: &T) -> Result<(), Error>
Encodes a required field directly into the shared buffer.
Auto Trait Implementations§
impl Freeze for MapEncodeBuffer
impl RefUnwindSafe for MapEncodeBuffer
impl Send for MapEncodeBuffer
impl Sync for MapEncodeBuffer
impl Unpin for MapEncodeBuffer
impl UnsafeUnpin for MapEncodeBuffer
impl UnwindSafe for MapEncodeBuffer
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