Trait Database

Source
pub trait Database {
    // Required methods
    fn is_ready<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn status<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn update<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        api: &'life1 SafeBrowsingApi,
        threat_lists: &'life2 [ThreatDescriptor],
    ) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn lookup<'life0, 'life1, 'async_trait>(
        &'life0 self,
        hash: &'life1 HashPrefix,
    ) -> Pin<Box<dyn Future<Output = Result<Option<(HashPrefix, Vec<ThreatDescriptor>)>, DatabaseError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn time_since_last_update<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Option<Duration>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stats<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = DatabaseStats> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Database interface for Safe Browsing

This trait defines the methods required for a Safe Browsing database implementation. It provides methods for looking up hash prefixes and updating the database from the Safe Browsing API.

Required Methods§

Source

fn is_ready<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the database is ready for queries

Source

fn status<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the current database status

Source

fn update<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, api: &'life1 SafeBrowsingApi, threat_lists: &'life2 [ThreatDescriptor], ) -> Pin<Box<dyn Future<Output = Result<(), DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Update the database with the latest threat lists

Source

fn lookup<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 HashPrefix, ) -> Pin<Box<dyn Future<Output = Result<Option<(HashPrefix, Vec<ThreatDescriptor>)>, DatabaseError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Look up a hash prefix in the database

If found, returns the matching hash prefix and the list of threat descriptors that contain it

Source

fn time_since_last_update<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Option<Duration>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the time since the last successful update

Source

fn stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = DatabaseStats> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get database statistics

Implementors§