pub struct PackedSessionWrite { /* private fields */ }Expand description
Packed write buffer for replacing one session’s chunk set.
A packed write stores all values for a session in one slab, reducing allocator work for KV-cache style batches.
Implementations§
Source§impl PackedSessionWrite
impl PackedSessionWrite
Sourcepub fn with_capacity(
session_prefix: Bytes,
item_capacity: usize,
value_bytes_capacity: usize,
) -> Self
pub fn with_capacity( session_prefix: Bytes, item_capacity: usize, value_bytes_capacity: usize, ) -> Self
Creates an empty packed session write with preallocated capacities.
Sourcepub fn from_owned_items(
session_prefix: Bytes,
items: Vec<(Bytes, Bytes)>,
) -> Self
pub fn from_owned_items( session_prefix: Bytes, items: Vec<(Bytes, Bytes)>, ) -> Self
Builds a packed session write from owned key/value pairs.
Sourcepub fn item_count(&self) -> usize
pub fn item_count(&self) -> usize
Returns the number of records in the packed write.
Sourcepub fn stored_bytes(&self) -> usize
pub fn stored_bytes(&self) -> usize
Returns the number of value bytes stored in the packed write.
Sourcepub fn session_prefix(&self) -> &[u8] ⓘ
pub fn session_prefix(&self) -> &[u8] ⓘ
Returns the session prefix this write replaces.
Sourcepub fn value_buffer_len(&self) -> usize
pub fn value_buffer_len(&self) -> usize
Returns the length of the contiguous value buffer.
Sourcepub fn value_buffer_mut(&mut self) -> &mut Vec<u8> ⓘ
pub fn value_buffer_mut(&mut self) -> &mut Vec<u8> ⓘ
Returns the mutable contiguous value buffer for custom packing.
Sourcepub fn push_owned_record(&mut self, key: Bytes, value: Bytes)
pub fn push_owned_record(&mut self, key: Bytes, value: Bytes)
Appends an owned key/value record to the packed write.
Sourcepub fn push_prepacked_record(&mut self, key: Bytes, offset: usize, len: usize)
pub fn push_prepacked_record(&mut self, key: Bytes, offset: usize, len: usize)
Appends a key whose value already lives in the packed value buffer.
Sourcepub fn cloned_records(&self) -> Vec<(Bytes, Bytes)>
pub fn cloned_records(&self) -> Vec<(Bytes, Bytes)>
Returns cloned key/value records for inspection or persistence.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PackedSessionWrite
impl RefUnwindSafe for PackedSessionWrite
impl Send for PackedSessionWrite
impl Sync for PackedSessionWrite
impl Unpin for PackedSessionWrite
impl UnsafeUnpin for PackedSessionWrite
impl UnwindSafe for PackedSessionWrite
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