pub trait DataStore: Default + Serialize {
// Provided methods
fn open<P>(db: P) -> AtomicDatabase<Self>
where P: AsRef<Path>,
Self: DeserializeOwned { ... }
fn open_in_memory() -> AtomicDatabase<Self>
where Self: DeserializeOwned { ... }
fn load(file: impl Read) -> Result<Self>
where Self: Sized + DeserializeOwned { ... }
fn save(&self, file: impl Write) -> Result<()> { ... }
}Expand description
This trait needs to be implemented for the Database struct. It requires a few implementations. The defined functions have default definitions.
Provided Methods§
Sourcefn open<P>(db: P) -> AtomicDatabase<Self>
fn open<P>(db: P) -> AtomicDatabase<Self>
Opens a Database by the specified path. If the Database doesn’t exist, this will create a new one! Wrap a Arc<_> around it to use it in parallel contexts!
Sourcefn open_in_memory() -> AtomicDatabase<Self>where
Self: DeserializeOwned,
fn open_in_memory() -> AtomicDatabase<Self>where
Self: DeserializeOwned,
Creates a Database instance in memory. Wrap a Arc<_> around it to use it in parallel contexts!
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.