pub(super) struct Db {
pool: SqlitePool,
}Expand description
Database handle for monolingual dictionary tables.
Fields§
§pool: SqlitePoolImplementations§
Source§impl Db
impl Db
pub(super) fn new(database: &Database) -> Self
Sourcepub(super) fn upsert_entry(
&self,
lang: &str,
entry: &DictionaryEntry,
) -> Result<(), Error>
pub(super) fn upsert_entry( &self, lang: &str, entry: &DictionaryEntry, ) -> Result<(), Error>
Inserts or replaces a single monolingual metadata entry.
The updated date is stored as a Unix epoch integer (midnight UTC).
§Errors
Returns an error if the database write fails.
Sourcepub(super) fn get_entry(
&self,
lang: &str,
) -> Result<Option<DictionaryEntry>, Error>
pub(super) fn get_entry( &self, lang: &str, ) -> Result<Option<DictionaryEntry>, Error>
Retrieves the cached metadata entry for a single language.
Returns None if no entry for lang has been cached yet.
§Errors
Returns an error if the database query fails.
Sourcepub(super) fn get_all_entries(
&self,
) -> Result<Vec<(String, DictionaryEntry)>, Error>
pub(super) fn get_all_entries( &self, ) -> Result<Vec<(String, DictionaryEntry)>, Error>
Retrieves all cached monolingual metadata entries.
Returns an empty Vec if no entries have been cached yet.
§Errors
Returns an error if the database query fails or any stored updated
timestamp cannot be converted to a NaiveDate.
Sourcepub(super) fn get_most_recent_cached_at(
&self,
) -> Result<Option<UnixTimestamp>, Error>
pub(super) fn get_most_recent_cached_at( &self, ) -> Result<Option<UnixTimestamp>, Error>
Returns the most recent cached_at value across all metadata entries.
Used to determine whether the metadata cache is stale relative to
the API’s Last-Modified header.
§Errors
Returns an error if the database query fails.
Sourcepub(super) fn record_install(
&self,
lang: &str,
installed_version: UnixTimestamp,
) -> Result<(), Error>
pub(super) fn record_install( &self, lang: &str, installed_version: UnixTimestamp, ) -> Result<(), Error>
Records that a dictionary was installed with the given version.
If a record already exists for lang, it is updated in place.
§Errors
Returns an error if the database write fails.
Sourcepub(super) fn remove_installed(&self, lang: &str) -> Result<(), Error>
pub(super) fn remove_installed(&self, lang: &str) -> Result<(), Error>
Removes the installed record for a language.
Called when a dictionary is deleted from the device.
§Errors
Returns an error if the database write fails.
Sourcepub(super) fn is_update_available(&self, lang: &str) -> Result<bool, Error>
pub(super) fn is_update_available(&self, lang: &str) -> Result<bool, Error>
Returns true if a newer version of the dictionary is available.
Compares updated from reader_dict_monolingual_metadata against
installed_version from reader_dict_monolingual_installed via a single SQL JOIN.
Returns false if the language is not installed or has no metadata.
§Errors
Returns an error if the database query fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Db
impl !RefUnwindSafe for Db
impl Send for Db
impl Sync for Db
impl Unpin for Db
impl UnsafeUnpin for Db
impl !UnwindSafe 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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