Expand description
FFI callback functions invoked by the ReadStat C library during parsing.
The ReadStat C parser uses a callback-driven architecture: as it reads a .sas7bdat
file, it invokes registered callbacks for metadata, variables, and values. Each
callback receives a raw *mut c_void context pointer that is cast back to the
appropriate Rust struct (ReadStatMetadata or ReadStatData) to accumulate
parsed results.
Enumsยง
- Read
Stat ๐Handler - Return codes for
ReadStatC callback functions.
Constantsยง
- DAY_
SHIFT ๐ - SAS epoch (1960-01-01) to Unix epoch (1970-01-01) offset in days.
- ROUND_
SCALE ๐ - Scale factor for rounding to 14 decimal places:
10^14. - SEC_
SHIFT ๐ - SAS epoch to Unix epoch offset in seconds.
Functionsยง
- catch_
callback ๐ - Contains Rust panics before they can unwind through C.
- checked_
f64_ ๐to_ i32 - Converts an
f64toi32, returningNonefor non-finite or out-of-range values instead of silently saturating. - checked_
f64_ ๐to_ i64 - Converts an
f64toi64, returningNonefor non-finite or out-of-range values instead of silently saturating (the behaviour of anascast). - handle_
metadata ๐ - FFI callback that extracts file-level metadata from the
ReadStatC parser. - handle_
metadata_ ๐inner - handle_
streaming_ ๐value - handle_
value ๐ - FFI callback that extracts a single cell value during row parsing.
- handle_
value_ ๐inner - handle_
variable ๐ - FFI callback that extracts per-variable metadata from the
ReadStatC parser. - handle_
variable_ ๐inner - round_
decimal_ ๐f32 - Rounds an f32 to 14 decimal places using pure arithmetic.
- round_
decimal_ ๐f64 - Rounds an f64 to 14 decimal places using pure arithmetic.
- row_
count_ ๐from_ c - sas_
datetime_ ๐to_ unix_ subsec - Converts a SAS datetime (seconds since 1960-01-01, possibly fractional) to
a Unix-epoch timestamp at the given sub-second
scale(1e3 for ms, 1e6 for ยตs, 1e9 for ns). Rounds rather than truncates: f64 representation error at SAS-datetime magnitudes (~1.9e9 s) is larger than one sub-second unit, so truncation would land one unit low about half the time. - sas_
time_ ๐to_ ms - Converts a SAS time (seconds since midnight, possibly fractional) to milliseconds, rounding rather than truncating.
- sas_
time_ ๐to_ ns - Converts a SAS time (seconds since midnight, possibly fractional) to nanoseconds, rounding rather than truncating.
- sas_
time_ ๐to_ us - Converts a SAS time (seconds since midnight, possibly fractional) to microseconds, rounding rather than truncating.