pub struct StorageHandle { /* private fields */ }
Expand description
A asynchronous wrapper around a SQLite database.
These operations will be ran in a background thread preventing any IO operations from blocking the async context.
Implementations§
Source§impl StorageHandle
impl StorageHandle
Sourcepub async fn open(path: impl AsRef<Path>) -> Result<Self>
pub async fn open(path: impl AsRef<Path>) -> Result<Self>
Connects to the SQLite database.
This spawns 1 background threads with actions being executed within that thread.
This approach reduces the affect of writes blocking reads and vice-versa.
Sourcepub async fn open_in_memory() -> Result<Self>
pub async fn open_in_memory() -> Result<Self>
Connects to a new in-memory SQLite database.
Sourcepub async fn execute<P>(&self, sql: impl AsRef<str>, params: P) -> Result<usize>
pub async fn execute<P>(&self, sql: impl AsRef<str>, params: P) -> Result<usize>
Execute a SQL statement with some provided parameters.
Sourcepub async fn execute_many<P>(
&self,
sql: impl AsRef<str>,
param_set: Vec<P>,
) -> Result<usize>
pub async fn execute_many<P>( &self, sql: impl AsRef<str>, param_set: Vec<P>, ) -> Result<usize>
Execute a SQL statement several times with some provided parameters.
The statement is executed within the same transaction.
Sourcepub async fn fetch_one<P, T>(
&self,
sql: impl AsRef<str>,
params: P,
) -> Result<Option<T>>
pub async fn fetch_one<P, T>( &self, sql: impl AsRef<str>, params: P, ) -> Result<Option<T>>
Fetch a single row from a given SQL statement with some provided parameters.
Trait Implementations§
Source§impl Clone for StorageHandle
impl Clone for StorageHandle
Source§fn clone(&self) -> StorageHandle
fn clone(&self) -> StorageHandle
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for StorageHandle
impl RefUnwindSafe for StorageHandle
impl Send for StorageHandle
impl Sync for StorageHandle
impl Unpin for StorageHandle
impl UnwindSafe for StorageHandle
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.