Skip to main content

decode_record

Function decode_record 

Source
pub fn decode_record(
    data: &[u8],
    columns: &[ColumnDef],
) -> Result<Vec<(String, EseValue)>, EseError>
Expand description

Decode an ESE data record into named column values.

§Record format (Vista+)

Offset 0:  last_fixed_col_id   (u8)  — highest fixed column ID in this record
Offset 1:  last_var_col_idx    (u8)  — count of variable columns in this record
Offset 2:  var_data_offset     (u16) — offset from record start to variable data
Offset 4…: fixed column data (packed, column_id 1 through last_fixed_col_id)
var_data_offset…end-of-var: variable column data
(var_data_offset - 4 - fixed_size) / 2 entries before var data: end offsets

Fixed-column data is packed contiguously in column_id order starting at byte 4. Each column occupies exactly fixed_col_size bytes regardless of nullity (null fixed columns are stored as zero bytes in their normal slot).

Variable columns follow: a 2-byte per-column end-offset array immediately before the variable data (end offsets relative to var_data_offset). High bit of an offset entry indicates a NULL variable column.

§Errors

Returns EseError::Corrupt if the header cannot be read or an offset is out of bounds. Unknown coltypes are returned as EseValue::Binary.