pub struct TempDb { /* private fields */ }Expand description
Data structure to keep the temporary file holding the database alive, because it will get unlinked on drop.
Implementations§
Source§impl TempDb
impl TempDb
Sourcepub async fn new() -> Result<Self>
pub async fn new() -> Result<Self>
Creates a new database at a temporary path.
§Errors
Returns anyhow::Error if we can’t:
- Create a new
NamedTempFilefor the database - Initialize the database at the temporary path
Methods from Deref<Target = Database>§
Sourcepub async fn count(&self) -> Result<i64, DatabaseError>
pub async fn count(&self) -> Result<i64, DatabaseError>
Queries the database to get a count of records it contains.
§Errors
Returns DatabaseError if the operation fails.
Sourcepub async fn insert(&self, record: DbRecord) -> Result<i64, DatabaseError>
pub async fn insert(&self, record: DbRecord) -> Result<i64, DatabaseError>
Inserts the given record into the Database.
Returns the ID of the inserted row.
§Errors
Returns DatabaseError if the insert operation fails.
Sourcepub async fn delete(&self, id: i64) -> Result<usize, DatabaseError>
pub async fn delete(&self, id: i64) -> Result<usize, DatabaseError>
Deletes the record corresponding to the given id.
§Errors
Returns DatabaseError if the operation fails.
Sourcepub async fn get_record(&self, id: i64) -> Result<DbRecord, DatabaseError>
pub async fn get_record(&self, id: i64) -> Result<DbRecord, DatabaseError>
Sourcepub async fn get_many_records(
&self,
ids: &[i64],
) -> Result<Vec<DbRecord>, DatabaseError>
pub async fn get_many_records( &self, ids: &[i64], ) -> Result<Vec<DbRecord>, DatabaseError>
Get multiple records from SQLite given their IDs.
§Errors
Returns DatabaseError if the operation fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TempDb
impl !RefUnwindSafe for TempDb
impl Send for TempDb
impl Sync for TempDb
impl Unpin for TempDb
impl !UnwindSafe for TempDb
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request