pub struct SlabView<'a> { /* private fields */ }Expand description
Parsed slab: header + drop records + view onto the solid window.
bytes borrows the underlying slab buffer for lifetime 'a. The
plaintext_for accessor returns slices that borrow from bytes,
so callers can keep those slices around as long as the slab buffer
itself stays alive.
Implementations§
Source§impl SlabView<'_>
impl SlabView<'_>
Sourcepub const fn header(&self) -> SlabHeader
pub const fn header(&self) -> SlabHeader
The slab header.
Sourcepub fn drop_records(&self) -> &[DropRecord]
pub fn drop_records(&self) -> &[DropRecord]
All drop records in this slab, in declaration order.
Sourcepub const fn solid_window_offset(&self) -> usize
pub const fn solid_window_offset(&self) -> usize
Byte offset where the solid window begins (i.e. immediately after the last drop record). Useful for diagnostics.
Sourcepub fn find_record(&self, drop_id: &[u8; 32]) -> Option<&DropRecord>
pub fn find_record(&self, drop_id: &[u8; 32]) -> Option<&DropRecord>
Find a drop record by its DropId. Linear scan.
Sourcepub fn plaintext_for(
&self,
drop_id: &[u8; 32],
) -> Option<Result<Vec<u8>, CoreError>>
pub fn plaintext_for( &self, drop_id: &[u8; 32], ) -> Option<Result<Vec<u8>, CoreError>>
Return the plaintext bytes for drop_id, or None if no drop
in this slab carries that id.
Supports both store (0x00) and LZ4 (0x01) codecs. LZ4 drops
are decompressed on read. Non-plaintext AEADs and non-zero
solid_window_index are still rejected (v0.1 limitations).
Returns owned bytes (not a borrowed slice) because LZ4 decompression produces new data that does not live in the slab buffer.
§Errors
CoreError::UnsupportedFeatureif the drop uses an unknown codec, a non-plaintext AEAD, or a non-zerosolid_window_index.CoreError::Corruptif the slice would extend past the slab or decompression fails.
Sourcepub fn plaintext_for_with_dict_lookup(
&self,
drop_id: &[u8; 32],
dict_lookup: &dyn Fn(u8) -> Option<Vec<u8>>,
) -> Option<Result<Vec<u8>, CoreError>>
pub fn plaintext_for_with_dict_lookup( &self, drop_id: &[u8; 32], dict_lookup: &dyn Fn(u8) -> Option<Vec<u8>>, ) -> Option<Result<Vec<u8>, CoreError>>
Same as plaintext_for but with a
callback to resolve dict_id → dictionary bytes. Used by
SlabStore when the manifest’s dictionary_section is
populated. For drops with dict_id == NO_DICT (0xFF), the
callback is not consulted.
The callback returns the raw dictionary bytes for the given
dict_id, or None if the dict is unknown (which makes the
drop undecodable).
Sourcepub fn plaintext_range(
&self,
drop_id: &[u8; 32],
off: u64,
len: usize,
) -> Option<Result<Vec<u8>, CoreError>>
pub fn plaintext_range( &self, drop_id: &[u8; 32], off: u64, len: usize, ) -> Option<Result<Vec<u8>, CoreError>>
Decompress only the plaintext bytes at [off, off+len) of
drop_id.
Seekable (slab v2) drops decode only the covering container
frames — a cold 8 KiB window costs at most one 256 KiB frame.
Non-seekable drops decode the full payload and slice (the
caller-side cache makes repeat windows cheap; see
crate::slab_cache).
Returns None if no drop in this slab carries that id.
off + len beyond the drop’s plaintext is Corrupt.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for SlabView<'a>
impl<'a> RefUnwindSafe for SlabView<'a>
impl<'a> Send for SlabView<'a>
impl<'a> Sync for SlabView<'a>
impl<'a> Unpin for SlabView<'a>
impl<'a> UnsafeUnpin for SlabView<'a>
impl<'a> UnwindSafe for SlabView<'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
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