pub struct ByteStringPool { /* private fields */ }Expand description
Append-only byte arena. Each interned byte sequence gets a stable
ByteStrView handle whose (offset, len) survives all subsequent
insertions (the underlying Vec<u8> may reallocate, but the indices
into it are stable).
Pool capacity:
bytes: up to 4 GiB total raw payload (u32offsets).offsets: up to 2³² distinct entries.lens: up to 2³² individual byte length (per-entry cap is also 2³²).
These limits are documented but not actively enforced beyond a
try_push API: in v3 use the pool well below those numbers; if a
future workload approaches the cap, promote to a u64-offset variant.
Implementations§
Source§impl ByteStringPool
impl ByteStringPool
Sourcepub fn push(&mut self, bytes: &[u8]) -> Result<ByteStrView, ByteDictError>
pub fn push(&mut self, bytes: &[u8]) -> Result<ByteStrView, ByteDictError>
Append a byte sequence and return a stable view.
Returns Err if the per-entry length exceeds u32::MAX or the
total byte payload would exceed u32::MAX. These limits are wide
enough that real-world pipelines never hit them, but we surface
them as errors rather than panic for safety at boundaries.
Sourcepub fn get(&self, view: ByteStrView) -> &[u8] ⓘ
pub fn get(&self, view: ByteStrView) -> &[u8] ⓘ
Resolve a view back to its byte slice. Panics in debug builds if the
view points outside the pool; in release builds returns an empty
slice for an out-of-bounds view (defensive — should never happen if
views are only constructed by push).
Sourcepub fn get_by_index(&self, idx: usize) -> Option<&[u8]>
pub fn get_by_index(&self, idx: usize) -> Option<&[u8]>
Resolve a view by entry index (position in insertion order).
Returns None if idx >= self.len().
Sourcepub fn iter(&self) -> impl Iterator<Item = (usize, &[u8])> + '_
pub fn iter(&self) -> impl Iterator<Item = (usize, &[u8])> + '_
Iterate (index, bytes) in insertion order. Deterministic.
Sourcepub fn iter_views(&self) -> impl Iterator<Item = ByteStrView> + '_
pub fn iter_views(&self) -> impl Iterator<Item = ByteStrView> + '_
Iterate views in insertion order. Use when you want to keep the
(offset, len) representation (e.g. to thread it through a
dictionary lookup).
Trait Implementations§
Source§impl Clone for ByteStringPool
impl Clone for ByteStringPool
Source§fn clone(&self) -> ByteStringPool
fn clone(&self) -> ByteStringPool
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ByteStringPool
impl Debug for ByteStringPool
Source§impl Default for ByteStringPool
impl Default for ByteStringPool
Source§fn default() -> ByteStringPool
fn default() -> ByteStringPool
Source§impl PartialEq for ByteStringPool
impl PartialEq for ByteStringPool
Source§fn eq(&self, other: &ByteStringPool) -> bool
fn eq(&self, other: &ByteStringPool) -> bool
self and other values to be equal, and is used by ==.impl Eq for ByteStringPool
impl StructuralPartialEq for ByteStringPool
Auto Trait Implementations§
impl Freeze for ByteStringPool
impl RefUnwindSafe for ByteStringPool
impl Send for ByteStringPool
impl Sync for ByteStringPool
impl Unpin for ByteStringPool
impl UnsafeUnpin for ByteStringPool
impl UnwindSafe for ByteStringPool
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more