pub struct Db(pub SqlitePool);Expand description
A pooled SQLite connection. Cheap to clone (shares the pool handle).
Queries run on rusqlite (blocking) under spawn_blocking via
Db::with_conn — a deliberate choice, not a stopgap: builtins called
from the (synchronous) Ling interpreter dispatch this way too, so one
blocking DB layer serves both the async HTTP side and the interpreter
bridge without two separate drivers.
Tuple Fields§
§0: SqlitePoolImplementations§
Source§impl Db
impl Db
Sourcepub async fn connect(path: impl AsRef<Path>) -> Result<Self>
pub async fn connect(path: impl AsRef<Path>) -> Result<Self>
Opens (creating if needed) a SQLite database file and returns a pool.
Sourcepub async fn connect_memory() -> Result<Self>
pub async fn connect_memory() -> Result<Self>
A private, shared-cache in-memory database — useful for tests and examples. All connections in the pool see the same data.
pub fn pool(&self) -> &SqlitePool
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Db
impl !UnwindSafe for Db
impl Freeze for Db
impl Send for Db
impl Sync for Db
impl Unpin for Db
impl UnsafeUnpin for Db
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more