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§
- Column
Affinity - A columns “affinity”. https://www.sqlite.org/datatype3.html#type_affinity
- Extended
Column Affinity - 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.
- Mprintf
Error - Possible error cases when calling
mprintf
, aka the sqlite3_mprintf function. - Value
Type - 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’szErrMsg
or xBestIndex’sidxStr
- result_
blob - Calls
sqlite3_result_blob
to represent that a function returns a blob with the given value. - result_
bool - Calls
result_int
withvalue=1
for true, orvalue=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 oncrate::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.