asqlite/lib.rs
1//! # asqlite - Async SQLite for Rust
2//!
3//! This library provides an API for accessing SQLite databases using
4//! async Rust.
5//!
6//! It wraps `libsqlite3`, dispatching operations in a background thread.
7//!
8//! # Usage
9//!
10//! Add to your `Cargo.toml`:
11//!
12//! ```toml
13//! [dependencies]
14#![doc = concat!(
15 r#"asqlite = { version = ""#,
16 env!("CARGO_PKG_VERSION"),
17 r#"", features = [ "bundled" ] }"#,
18)]
19//! ```
20//!
21//! Unless you are writing a library, you probably want to enable the `bundled`
22//! feature, which automatically compiles SQLite.
23//! See [Cargo features](#cargo-features) for more.
24//!
25//! Start by creating a [`Connection`] via [`Connection::builder`].
26//!
27//! # Example
28//!
29//! ```
30#![doc = include_str!("../examples/apple.rs")]
31//! ```
32//!
33//! # Cancel safety
34//!
35//! All operations of this library are cancel-safe and can be used with,
36//! for example, `tokio::select!`.
37//!
38//! # Cargo features
39//!
40//! * `bundled` (disabled by default): automatically compiles and statically
41//! links an up to date version of SQLite to the library. This is a very
42//! good choice for most applications.
43
44#![allow(clippy::type_complexity)]
45#![warn(missing_docs, unreachable_pub)]
46#![deny(unsafe_op_in_unsafe_fn)]
47
48#[macro_use]
49mod macros;
50mod blob;
51mod connection;
52pub mod convert;
53mod error;
54mod internal;
55mod statement;
56mod utils;
57
58pub use self::{
59 blob::Blob,
60 connection::{Connection, ConnectionBuilder, InterruptHandle},
61 error::{Error, ErrorKind},
62 statement::Statement,
63};
64
65/// Alias for `Result<T, Error>`.
66pub type Result<T, E = Error> = std::result::Result<T, E>;
67
68/// A zero filled binary blob.
69#[derive(Clone, Copy, Debug, PartialEq, Eq)]
70pub struct ZeroBlob(
71 /// Size of the blob.
72 pub u64,
73);
74
75/// Open mode for blobs.
76#[derive(Clone, Copy, Debug, PartialEq, Eq)]
77#[repr(u8)]
78pub enum BlobOpenMode {
79 /// Read-only.
80 ReadOnly = 0,
81
82 /// Read and write.
83 ReadWrite = 1,
84}