pub struct TupleDecoder { /* private fields */ }Expand description
Decodes fields from Binary Tuples according to a fixed schema.
Reusable: create once per schema, decode many tuples. Precomputes byte offsets for O(1) field access.
Implementations§
Source§impl TupleDecoder
impl TupleDecoder
Sourcepub fn new(schema: &StrictSchema) -> Self
pub fn new(schema: &StrictSchema) -> Self
Create a decoder for the given schema.
Sourcepub fn schema_version(&self, tuple: &[u8]) -> Result<u16, StrictError>
pub fn schema_version(&self, tuple: &[u8]) -> Result<u16, StrictError>
Read the schema version from a tuple’s header.
Sourcepub fn is_null(&self, tuple: &[u8], col_idx: usize) -> Result<bool, StrictError>
pub fn is_null(&self, tuple: &[u8], col_idx: usize) -> Result<bool, StrictError>
Check whether column col_idx is null in the given tuple.
Sourcepub fn extract_fixed_raw<'a>(
&self,
tuple: &'a [u8],
col_idx: usize,
) -> Result<Option<&'a [u8]>, StrictError>
pub fn extract_fixed_raw<'a>( &self, tuple: &'a [u8], col_idx: usize, ) -> Result<Option<&'a [u8]>, StrictError>
Extract raw bytes for a fixed-size column. Returns None if null.
This is the O(1) fast path: a single bounds check + pointer slice.
Sourcepub fn extract_variable_raw<'a>(
&self,
tuple: &'a [u8],
col_idx: usize,
) -> Result<Option<&'a [u8]>, StrictError>
pub fn extract_variable_raw<'a>( &self, tuple: &'a [u8], col_idx: usize, ) -> Result<Option<&'a [u8]>, StrictError>
Extract raw bytes for a variable-length column. Returns None if null.
Reads two entries from the offset table to determine start and length.
Sourcepub fn extract_value(
&self,
tuple: &[u8],
col_idx: usize,
) -> Result<Value, StrictError>
pub fn extract_value( &self, tuple: &[u8], col_idx: usize, ) -> Result<Value, StrictError>
Extract a column value as a Value, performing type-aware decoding.
This is the general-purpose extraction path. For hot paths, prefer
extract_fixed_raw / extract_variable_raw to avoid Value allocation.
Sourcepub fn extract_all(&self, tuple: &[u8]) -> Result<Vec<Value>, StrictError>
pub fn extract_all(&self, tuple: &[u8]) -> Result<Vec<Value>, StrictError>
Extract all columns from a tuple into a Vec
Sourcepub fn extract_by_name(
&self,
tuple: &[u8],
name: &str,
) -> Result<Value, StrictError>
pub fn extract_by_name( &self, tuple: &[u8], name: &str, ) -> Result<Value, StrictError>
Extract a column by name.
Sourcepub fn extract_value_versioned(
&self,
tuple: &[u8],
col_idx: usize,
old_col_count: usize,
) -> Result<Value, StrictError>
pub fn extract_value_versioned( &self, tuple: &[u8], col_idx: usize, old_col_count: usize, ) -> Result<Value, StrictError>
Decode a tuple written with an older schema version.
Columns present in the old schema are extracted normally. Columns added in newer schema versions return their default value or null.
old_col_count is the number of columns in the schema version that
wrote this tuple.
Sourcepub fn schema(&self) -> &StrictSchema
pub fn schema(&self) -> &StrictSchema
Access the schema this decoder was built for.
Sourcepub fn fixed_section_start(&self) -> usize
pub fn fixed_section_start(&self) -> usize
Byte offset where fixed-field section starts.
Sourcepub fn offset_table_start(&self) -> usize
pub fn offset_table_start(&self) -> usize
Byte offset where the variable offset table starts.
Sourcepub fn var_data_start(&self) -> usize
pub fn var_data_start(&self) -> usize
Byte offset where variable data starts.
Sourcepub fn fixed_field_location(&self, col_idx: usize) -> Option<(usize, usize)>
pub fn fixed_field_location(&self, col_idx: usize) -> Option<(usize, usize)>
Byte offset and size for a fixed column (relative to tuple start).
Returns None if the column is variable-length.
Sourcepub fn var_field_index(&self, col_idx: usize) -> Option<usize>
pub fn var_field_index(&self, col_idx: usize) -> Option<usize>
Index in the variable offset table for a column.
Returns None if the column is fixed-size.
Auto Trait Implementations§
impl Freeze for TupleDecoder
impl RefUnwindSafe for TupleDecoder
impl Send for TupleDecoder
impl Sync for TupleDecoder
impl Unpin for TupleDecoder
impl UnsafeUnpin for TupleDecoder
impl UnwindSafe for TupleDecoder
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.