Skip to main content

TupleDecoder

Struct TupleDecoder 

Source
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

Source

pub fn new(schema: &StrictSchema) -> Self

Create a decoder for the given schema.

Source

pub fn schema_version(&self, tuple: &[u8]) -> Result<u32, StrictError>

Read and validate the header, then return the schema version.

Validates magic bytes at [0..4] and format version at [4] before returning the schema version at [5..9].

Source

pub fn is_null(&self, tuple: &[u8], col_idx: usize) -> Result<bool, StrictError>

Check whether column col_idx is null in the given tuple.

Source

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.

Source

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.

Source

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.

Source

pub fn extract_all(&self, tuple: &[u8]) -> Result<Vec<Value>, StrictError>

Extract all columns from a tuple into a Vec.

Source

pub fn extract_by_name( &self, tuple: &[u8], name: &str, ) -> Result<Value, StrictError>

Extract a column by name.

Source

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 declared default value, or Value::Null for nullable columns without a default.

old_col_count is the number of columns in the schema version that wrote this tuple.

Correctness invariant: a non-nullable column added via ALTER ADD COLUMN ... NOT NULL DEFAULT <expr> will always return the materialized default, never Value::Null. The ALTER path rejects NOT NULL without a DEFAULT, so every non-nullable column in the schema must have col.default populated.

Source

pub fn schema(&self) -> &StrictSchema

Access the schema this decoder was built for.

Source

pub fn extract_bitemporal_timestamps( &self, tuple: &[u8], ) -> Result<(i64, i64, i64), StrictError>

Extract the three bitemporal timestamps from a tuple: (system_from_ms, valid_from_ms, valid_until_ms). Only valid for schemas constructed with StrictSchema::new_bitemporal.

Source

pub fn fixed_section_start(&self) -> usize

Byte offset where fixed-field section starts.

Source

pub fn offset_table_start(&self) -> usize

Byte offset where the variable offset table starts.

Source

pub fn var_data_start(&self) -> usize

Byte offset where variable data starts.

Source

pub fn var_count(&self) -> usize

Number of variable-length columns in the schema.

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,