Debian Codegraph @

src/sqlite/mod.rs

raw
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
7 pub(crate) mod backend;
8 mod connection;
9 pub mod expression;
10
11 pub mod query_builder;
12
13 mod types;
14
15 pub use self::backend::{Sqlite, SqliteType};
16 pub use self::connection::SerializedDatabase;
17 pub use self::connection::SqliteBindValue;
18 pub use self::connection::SqliteConnection;
19 pub use self::connection::SqliteValue;
20 pub use self::query_builder::SqliteQueryBuilder;
21
22 /// Trait for the implementation of a SQLite aggregate function
23 ///
24 /// This trait is to be used in conjunction with the `define_sql_function!`
25 /// macro for defining a custom SQLite aggregate function. See
26 /// the documentation [there](super::prelude::define_sql_function!) for details.
27 pub trait SqliteAggregateFunction<Args>: Default {
28 /// The result type of the SQLite aggregate function
29 type Output;
30
31 /// The `step()` method is called once for every record of the query.
32 ///
33 /// This is called through a C FFI, as such panics do not propagate to the caller. Panics are
34 /// caught and cause a return with an error value. The implementation must still ensure that
35 /// state remains in a valid state (refer to [`std::panic::UnwindSafe`] for a bit more detail).
36 fn step(&mut self, args: Args);
37
38 /// After the last row has been processed, the `finalize()` method is
39 /// called to compute the result of the aggregate function. If no rows
40 /// were processed `aggregator` will be `None` and `finalize()` can be
41 /// used to specify a default result.
42 ///
43 /// This is called through a C FFI, as such panics do not propagate to the caller. Panics are
44 /// caught and cause a return with an error value.
45 fn finalize(aggregator: Option<Self>) -> Self::Output;
46 }
47
48 /// SQLite specific sql types
49 pub mod sql_types {
50 #[doc(inline)]
51 pub use super::types::Timestamptz;
52 }