Struct datacake_sqlite::StorageHandle
source · 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>where
P: Params + Clone + Send + 'static,
pub async fn execute<P>(&self, sql: impl AsRef<str>, params: P) -> Result<usize>where P: Params + Clone + Send + 'static,
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>where
P: Params + Clone + Send + 'static,
pub async fn execute_many<P>( &self, sql: impl AsRef<str>, param_set: Vec<P> ) -> Result<usize>where P: Params + Clone + Send + 'static,
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>>where
P: Params + Send + 'static,
T: FromRow + Send + 'static,
pub async fn fetch_one<P, T>( &self, sql: impl AsRef<str>, params: P ) -> Result<Option<T>>where P: Params + Send + 'static, T: FromRow + Send + 'static,
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 copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl RefUnwindSafe for StorageHandle
impl Send for StorageHandle
impl Sync for StorageHandle
impl Unpin for StorageHandle
impl UnwindSafe for StorageHandle
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§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.
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
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>
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§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.