Skip to main content

Module cb

Module cb 

Source
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ยง

ReadStatHandler ๐Ÿ”’
Return codes for ReadStat C 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 f64 to i32, returning None for non-finite or out-of-range values instead of silently saturating.
checked_f64_to_i64 ๐Ÿ”’
Converts an f64 to i64, returning None for non-finite or out-of-range values instead of silently saturating (the behaviour of an as cast).
handle_metadata ๐Ÿ”’
FFI callback that extracts file-level metadata from the ReadStat C 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 ReadStat C 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.