diesel/sqlite/mod.rs
1//! Provides types and functions related to working with SQLite
2//!
3//! Much of this module is re-exported from database agnostic locations.
4//! However, if you are writing code specifically to extend Diesel on
5//! SQLite, you may need to work with this module directly.
6
7mod auto_extension;
8pub(crate) mod backend;
9mod connection;
10pub mod expression;
11
12pub mod query_builder;
13
14mod types;
15
16pub use self::auto_extension::cancel_auto_extension;
17pub use self::auto_extension::register_auto_extension;
18pub use self::auto_extension::reset_auto_extension;
19pub use self::backend::{Sqlite, SqliteType};
20pub use self::connection::SerializedDatabase;
21pub use self::connection::SqliteBindValue;
22pub use self::connection::SqliteConnection;
23pub use self::connection::SqliteValue;
24pub use self::connection::sqlite_blob::SqliteReadOnlyBlob;
25pub use self::query_builder::SqliteQueryBuilder;
26
27/// Trait for the implementation of a SQLite aggregate function
28///
29/// This trait is to be used in conjunction with the `define_sql_function!`
30/// macro for defining a custom SQLite aggregate function. See
31/// the documentation [there](super::prelude::define_sql_function!) for details.
32pub trait SqliteAggregateFunction<Args>: Default {
33 /// The result type of the SQLite aggregate function
34 type Output;
35
36 /// The `step()` method is called once for every record of the query.
37 ///
38 /// This is called through a C FFI, as such panics do not propagate to the caller. Panics are
39 /// caught and cause a return with an error value. The implementation must still ensure that
40 /// state remains in a valid state (refer to [`std::panic::UnwindSafe`] for a bit more detail).
41 fn step(&mut self, args: Args);
42
43 /// After the last row has been processed, the `finalize()` method is
44 /// called to compute the result of the aggregate function. If no rows
45 /// were processed `aggregator` will be `None` and `finalize()` can be
46 /// used to specify a default result.
47 ///
48 /// This is called through a C FFI, as such panics do not propagate to the caller. Panics are
49 /// caught and cause a return with an error value.
50 fn finalize(aggregator: Option<Self>) -> Self::Output;
51}
52
53/// SQLite specific sql types
54pub mod sql_types {
55 #[doc(inline)]
56 pub use super::types::Timestamptz;
57
58 #[cfg(feature = "__sqlite-shared")]
59 #[doc(inline)]
60 pub use super::types::JsonValidFlags;
61}
62
63#[cfg(feature = "__sqlite-shared")]
64pub use self::types::JsonValidFlag;