pub struct StrListRef<'a> { /* private fields */ }Expand description
A borrowed, read-only view over string list data.
StrListRef borrows &[u8] (data) and &[u32] (boundary table) and provides
the same read-only API as StrList. Use it for
zero-copy views over external buffers (e.g., memory-mapped files).
§Invariants
Same as StrList: data is valid UTF-8 and ends are valid boundaries.
When constructed via new, these invariants are validated.
When constructed via From<&StrStack> or From<&StrList>, they are inherited.
Implementations§
Source§impl<'a> StrListRef<'a>
impl<'a> StrListRef<'a>
Sourcepub fn new(
data: &'a [u8],
ends: &'a [u32],
) -> Result<Self, StrListValidationError>
pub fn new( data: &'a [u8], ends: &'a [u32], ) -> Result<Self, StrListValidationError>
Creates a StrListRef from raw data and boundary slices, validating
UTF-8 and boundary consistency.
Validation checks (O(total bytes)):
endsvalues are monotonically non-decreasing- Last value does not exceed
data.len() - Each segment
data[ends[i-1]..ends[i]](withends[-1] = 0) is valid UTF-8
Sourcepub fn get(&self, index: usize) -> Option<&'a str>
pub fn get(&self, index: usize) -> Option<&'a str>
Returns the segment at index, or None if out of bounds.
Sourcepub fn get_bounds(&self, index: usize) -> Option<(u32, u32)>
pub fn get_bounds(&self, index: usize) -> Option<(u32, u32)>
Returns the byte offset bounds (start, end) for the segment at index.
Sourcepub fn iter(&self) -> StrListIter<'a> ⓘ
pub fn iter(&self) -> StrListIter<'a> ⓘ
Returns an iterator over the string segments.
Trait Implementations§
Source§impl<'a> Clone for StrListRef<'a>
impl<'a> Clone for StrListRef<'a>
Source§fn clone(&self) -> StrListRef<'a>
fn clone(&self) -> StrListRef<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for StrListRef<'a>
impl<'a> Debug for StrListRef<'a>
Source§impl<'a> From<&'a StrList> for StrListRef<'a>
impl<'a> From<&'a StrList> for StrListRef<'a>
Source§impl<'a> From<&'a StrStack> for StrListRef<'a>
impl<'a> From<&'a StrStack> for StrListRef<'a>
Source§impl<'a> IntoIterator for StrListRef<'a>
impl<'a> IntoIterator for StrListRef<'a>
Source§impl<'a> PartialEq for StrListRef<'a>
impl<'a> PartialEq for StrListRef<'a>
impl<'a> Copy for StrListRef<'a>
impl<'a> Eq for StrListRef<'a>
impl<'a> StructuralPartialEq for StrListRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for StrListRef<'a>
impl<'a> RefUnwindSafe for StrListRef<'a>
impl<'a> Send for StrListRef<'a>
impl<'a> Sync for StrListRef<'a>
impl<'a> Unpin for StrListRef<'a>
impl<'a> UnsafeUnpin for StrListRef<'a>
impl<'a> UnwindSafe for StrListRef<'a>
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