pub struct ReadStatMetadata {Show 13 fields
pub row_count: i32,
pub var_count: i32,
pub table_name: String,
pub file_label: String,
pub file_encoding: String,
pub version: i32,
pub is64bit: i32,
pub creation_time: String,
pub modified_time: String,
pub compression: ReadStatCompress,
pub endianness: ReadStatEndian,
pub vars: BTreeMap<i32, ReadStatVarMetadata>,
pub schema: Schema,
}Expand description
File-level metadata extracted from a .sas7bdat file.
Populated by the handle_metadata and handle_variable FFI callbacks during parsing.
After parsing, call read_metadata to populate
all fields and build the Arrow [Schema].
Fields§
§row_count: i32Number of rows (observations) in the dataset.
var_count: i32Number of variables (columns) in the dataset.
table_name: StringInternal table name from the SAS file header.
file_label: StringUser-assigned file label.
file_encoding: StringCharacter encoding of the file (e.g. "UTF-8", "WINDOWS-1252").
version: i32SAS file format version number.
is64bit: i32Whether the file uses 64-bit format (0 = 32-bit, 1 = 64-bit).
creation_time: StringFile creation timestamp (formatted as YYYY-MM-DD HH:MM:SS).
modified_time: StringFile modification timestamp (formatted as YYYY-MM-DD HH:MM:SS).
compression: ReadStatCompressCompression method used in the file.
endianness: ReadStatEndianByte order (endianness) of the file.
vars: BTreeMap<i32, ReadStatVarMetadata>Per-variable metadata, keyed by variable index.
schema: SchemaArrow schema derived from variable types. Not serialized.
Implementations§
Source§impl ReadStatMetadata
impl ReadStatMetadata
fn initialize_schema(&self) -> Schema
Sourcepub fn read_metadata(
&mut self,
rsp: &ReadStatPath,
skip_row_count: bool,
) -> Result<(), ReadStatError>
pub fn read_metadata( &mut self, rsp: &ReadStatPath, skip_row_count: bool, ) -> Result<(), ReadStatError>
Parses metadata from the .sas7bdat file referenced by rsp.
Sets up the ReadStat C parser with metadata and variable handlers, then
invokes parsing. On success, builds the Arrow [Schema] from the
discovered variable types. If skip_row_count is true, sets a row
limit of 1 to skip counting all rows (faster for metadata-only queries).
§Errors
Returns ReadStatError if FFI parsing fails.
Sourcepub fn read_metadata_from_bytes(
&mut self,
bytes: &[u8],
skip_row_count: bool,
) -> Result<(), ReadStatError>
pub fn read_metadata_from_bytes( &mut self, bytes: &[u8], skip_row_count: bool, ) -> Result<(), ReadStatError>
Parses metadata from an in-memory byte slice containing .sas7bdat data.
Equivalent to read_metadata but reads from
a &[u8] buffer instead of a file path. Useful for WASM targets, cloud storage,
HTTP uploads, and testing without filesystem access.
§Errors
Returns ReadStatError if FFI parsing fails.
§Panics
Panics if the dummy path CString allocation fails (should never happen).
Sourcepub fn read_metadata_from_mmap(
&mut self,
path: &Path,
skip_row_count: bool,
) -> Result<(), ReadStatError>
pub fn read_metadata_from_mmap( &mut self, path: &Path, skip_row_count: bool, ) -> Result<(), ReadStatError>
Parses metadata from a memory-mapped .sas7bdat file.
Opens the file at path and memory-maps it, avoiding explicit read syscalls.
The OS loads pages on demand and manages caching automatically. This is
especially beneficial for large files where it avoids copying file data
through kernel buffers.
§Safety
Memory mapping is safe as long as the file is not modified or truncated by
another process while the map is active. This is the standard expectation
for .sas7bdat files, which are read-only artifacts.
§Errors
Returns ReadStatError if the file cannot be opened, mapped, or parsed.
Sourcepub fn parse_columns_file(path: &Path) -> Result<Vec<String>, ReadStatError>
pub fn parse_columns_file(path: &Path) -> Result<Vec<String>, ReadStatError>
Parses a columns file, returning column names.
Lines starting with # are treated as comments and blank lines are skipped.
Each remaining line is trimmed and used as a column name.
§Errors
Returns ReadStatError if the file cannot be read.
Sourcepub fn resolve_selected_columns(
&self,
columns: Option<Vec<String>>,
) -> Result<Option<BTreeMap<i32, i32>>, ReadStatError>
pub fn resolve_selected_columns( &self, columns: Option<Vec<String>>, ) -> Result<Option<BTreeMap<i32, i32>>, ReadStatError>
Validates column names against the dataset’s variables and returns a mapping of original variable index to new contiguous index.
Returns Ok(None) if columns is None (no filtering requested).
Returns Err(ColumnsNotFound) if any requested names are not in the dataset.
§Errors
Returns ReadStatError::ColumnsNotFound if any requested column names
do not exist in the dataset.
Sourcepub fn filter_to_selected_columns(&self, mapping: &BTreeMap<i32, i32>) -> Self
pub fn filter_to_selected_columns(&self, mapping: &BTreeMap<i32, i32>) -> Self
Returns a new ReadStatMetadata with only the selected variables,
re-keyed with contiguous indices starting from 0.
Constructs the result directly instead of cloning the full struct, avoiding a deep clone of unselected variables and the original schema.
Trait Implementations§
Source§impl Clone for ReadStatMetadata
impl Clone for ReadStatMetadata
Source§fn clone(&self) -> ReadStatMetadata
fn clone(&self) -> ReadStatMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ReadStatMetadata
impl Debug for ReadStatMetadata
Source§impl Default for ReadStatMetadata
impl Default for ReadStatMetadata
Auto Trait Implementations§
impl Freeze for ReadStatMetadata
impl RefUnwindSafe for ReadStatMetadata
impl Send for ReadStatMetadata
impl Sync for ReadStatMetadata
impl Unpin for ReadStatMetadata
impl UnwindSafe for ReadStatMetadata
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