glite/decode
Types
A decoder that extracts a typed value from a row (list of columns).
pub opaque type RowDecoder(a)
A decoder that extracts a typed value from a single cell.
pub type ValueDecoder(a) =
fn(value.Value) -> Result(a, error.Error)
Values
pub fn blob(val: value.Value) -> Result(BitArray, error.Error)
Decode a blob (binary data) value.
pub fn bool(val: value.Value) -> Result(Bool, error.Error)
Decode a boolean value (SQLite stores as Integer 0/1).
pub fn dynamic(
val: value.Value,
) -> Result(value.Value, error.Error)
Decode any value as-is (always succeeds, returns the raw Value).
pub fn element(
index: Int,
decoder: fn(value.Value) -> Result(a, error.Error),
next: fn(a) -> RowDecoder(b),
) -> RowDecoder(b)
Decode the element at a given column index using a value decoder.
Designed for use with Gleam’s use syntax.
pub fn optional(
decoder: fn(value.Value) -> Result(a, error.Error),
) -> fn(value.Value) -> Result(option.Option(a), error.Error)
Make any value decoder nullable (NULL-safe).
Returns Ok(None) for NULL, Ok(Some(val)) for non-NULL.
pub fn run(
decoder: RowDecoder(a),
row: List(value.Value),
) -> Result(a, error.Error)
Run a decoder on a row.