Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend {
    // Required methods
    fn location(&self) -> String;
    fn open(&self, name: &str) -> Result<Box<dyn StoredDatabase>, LoadError>;
    fn drop_databases(&self, matches: &dyn Fn(&str) -> bool) -> DroppedDatabases;

    // Provided method
    fn collect_databases(&self, except: &str, now: f64, max_age: f64) { ... }
}
Expand description

A place that keeps a client’s databases, such as a directory of SQLite files. Every call is on the client’s thread.

Required Methods§

Source

fn location(&self) -> String

Where the databases are, such as sqlite:/path/to/dir. Clients on this thread with the same location and database name share one open database, as JS tabs share one IndexedDB database.

Source

fn open(&self, name: &str) -> Result<Box<dyn StoredDatabase>, LoadError>

Opens the database name, a new empty one if there is none. name can hold any character.

Source

fn drop_databases(&self, matches: &dyn Fn(&str) -> bool) -> DroppedDatabases

Deletes the databases that aren’t open whose name matches.

Provided Methods§

Source

fn collect_databases(&self, except: &str, now: f64, max_age: f64)

Deletes, in the background, the databases other than except that no client used for max_age ms since now (collectIDBDatabases), such as those of an older schema. Optional.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§