pub struct DatabaseHandler {
pub persist: bool,
pub crawl_id: Option<String>,
pub seeded: bool,
/* private fields */
}Expand description
Manage Sqlite database operations
Fields§
§persist: boolPersist after drop.
crawl_id: Option<String>The crawl ID.
seeded: boolInitial seed ran.
Implementations§
Source§impl DatabaseHandler
impl DatabaseHandler
Sourcepub fn pool_inited(&self) -> bool
pub fn pool_inited(&self) -> bool
Determine if the pool is initialized.
Sourcepub fn set_seeded(&mut self, seeded: bool)
pub fn set_seeded(&mut self, seeded: bool)
Set the seeded state
Sourcepub fn set_persisted(&mut self, persist: bool)
pub fn set_persisted(&mut self, persist: bool)
Set the persist state
Sourcepub async fn generate_pool(&self) -> SqlitePool
pub async fn generate_pool(&self) -> SqlitePool
Generate a sqlite pool.
Sourcepub async fn initlaize_pool(&self)
pub async fn initlaize_pool(&self)
Get or initialize the database pool
Sourcepub async fn set_pool(&self, pool: SqlitePool)
pub async fn set_pool(&self, pool: SqlitePool)
Set the pool directly.
Sourcepub async fn get_db_pool(&self) -> &SqlitePool
pub async fn get_db_pool(&self) -> &SqlitePool
Get or initialize the database pool
Sourcepub async fn url_exists(&self, pool: &SqlitePool, url_to_check: &str) -> bool
pub async fn url_exists(&self, pool: &SqlitePool, url_to_check: &str) -> bool
Check if a URL exists (ignore case)
Sourcepub async fn signature_exists(
&self,
pool: &SqlitePool,
signature_to_check: u64,
) -> bool
pub async fn signature_exists( &self, pool: &SqlitePool, signature_to_check: u64, ) -> bool
Check if a signature exists (ignore case)
Sourcepub async fn insert_url(&self, pool: &SqlitePool, new_url: &str)
pub async fn insert_url(&self, pool: &SqlitePool, new_url: &str)
Insert a new URL if it doesn’t exist
Sourcepub async fn insert_signature(&self, pool: &SqlitePool, new_signature: u64)
pub async fn insert_signature(&self, pool: &SqlitePool, new_signature: u64)
Insert a new signature if it doesn’t exist
Sourcepub async fn seed(
&self,
pool: &SqlitePool,
urls: HashSet<CaseInsensitiveString>,
) -> Result<HashSet<CaseInsensitiveString>, Error>
pub async fn seed( &self, pool: &SqlitePool, urls: HashSet<CaseInsensitiveString>, ) -> Result<HashSet<CaseInsensitiveString>, Error>
Seed the database and manage URLs
Sourcepub async fn count_records(pool: &SqlitePool) -> Result<u64, Error>
pub async fn count_records(pool: &SqlitePool) -> Result<u64, Error>
Count the records stored.
Sourcepub async fn get_all_resources(
pool: &SqlitePool,
) -> Result<HashSet<CaseInsensitiveString>, Error>
pub async fn get_all_resources( pool: &SqlitePool, ) -> Result<HashSet<CaseInsensitiveString>, Error>
Get all the resources stored.
Sourcepub fn delete_db_by_id(&self)
pub fn delete_db_by_id(&self)
Clear DB by id
Sourcepub async fn clear_table(pool: &SqlitePool) -> Result<(), Error>
pub async fn clear_table(pool: &SqlitePool) -> Result<(), Error>
Clear the resources table.
Trait Implementations§
Source§impl Clone for DatabaseHandler
impl Clone for DatabaseHandler
Source§fn clone(&self) -> DatabaseHandler
fn clone(&self) -> DatabaseHandler
Returns a duplicate 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 moreSource§impl Debug for DatabaseHandler
impl Debug for DatabaseHandler
Source§impl Default for DatabaseHandler
impl Default for DatabaseHandler
Source§fn default() -> DatabaseHandler
fn default() -> DatabaseHandler
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for DatabaseHandler
impl !RefUnwindSafe for DatabaseHandler
impl Send for DatabaseHandler
impl Sync for DatabaseHandler
impl Unpin for DatabaseHandler
impl UnsafeUnpin for DatabaseHandler
impl !UnwindSafe for DatabaseHandler
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