Module api

Source
Expand description

(Mostly) safe wrappers around low-level sqlite3 C API.

Uses the unsafe low-level API’s defined in crate::ext.

Useful when working with sqlite3_value or sqlite3_context.

Structs§

Value
Ergonomic wrapper around a raw sqlite3_value. It is the caller’s reponsibility to ensure that a given pointer points to a valid sqlite3_value object. There seems to be a 5-10% perf cost when using Value vs calling functions on raw pointers

Enums§

ColumnAffinity
A columns “affinity”. https://www.sqlite.org/datatype3.html#type_affinity
ExtendedColumnAffinity
A columns “extended affinity”. The traditional affinity does not include supplementary “types” that SQLite doesn’t support out of the box, like JSON, boolean, or datetime. This is an experimental extension to tradition affinities, and may change anytime.
MprintfError
Possible error cases when calling mprintf, aka the sqlite3_mprintf function.
ValueType
Possible values that sqlite3_value_type will return for a value.

Functions§

auxdata_get
sqlite3_get_auxdata
auxdata_set
sqlite3_set_auxdata
mprintf
Calls sqlite3_mprintf on the given string, with memory allocated by sqlite3. Meant to be passed into sqlite APIs that require sqlite-allocated strings, like virtual table’s zErrMsg or xBestIndex’s idxStr
result_blob
Calls sqlite3_result_blob to represent that a function returns a blob with the given value.
result_bool
Calls result_int with value=1 for true, or value=0 for false.
result_double
Calls sqlite3_result_double to represent that a function returns a double/float with the given value.
result_error
Calls sqlite3_result_error to represent that a function returns an error with the given value. Note: You can typically rely on crate::Result to do this for you.
result_error_code
Calls sqlite3_result_error_code to represent that a function returns xx with the given value.
result_int
Calls sqlite3_result_int to represent that a function returns an int32 with the given value.
result_int64
sqlite3_result_int64 to represent that a function returns an int64 with the given value.
result_json
Result the given JSON as a value that other SQLite JSON functions expect: a stringified text result with subtype of ‘J’.
result_null
Calls sqlite3_result_null to represent that a function returns null with the given value.
result_pointer
sqlite3_result_pointer
result_subtype
Calls sqlite3_result_subtype
result_text
Calls sqlite3_result_text to represent that a function returns a string with the given value. Fails if the string length is larger than i32 maximum value.
value_blob
Returns the sqlite3_value_blob result from the given sqlite3_value, as a u8 slice.
value_bytes
Returns the sqlite3_value_bytes result from the given sqlite3_value, as i32.
value_double
Returns the sqlite3_value_double result from the given sqlite3_value, as f64.
value_int
Returns the sqlite3_value_int result from the given sqlite3_value, as i32.
value_int64
Returns the sqlite3_value_int64 result from the given sqlite3_value, as i64.
value_pointer
sqlite3_value_pointer
value_text
Returns the sqlite3_value_text result from the given sqlite3_value, as a str. If the number of bytes of the underlying value is 0, then an empty string is returned. A UTF8 Error is returned if there are problems encoding the string.
value_text_notnull
value_type
Returns the sqlite3_value_type result of the given value, one of TEXT/INT/FLOAT/BLOB/NULL.