mod directory;
mod memory;
mod transient;
#[cfg(all(feature = "web", target_arch = "wasm32"))]
mod web;
use serde_json::Value;
use std::any::Any;
use std::fmt::Debug;
use std::io::Result;
pub use directory::{DirectoryConfig, DirectoryStore};
pub use memory::{MemoryConfig, MemoryStore};
pub use transient::TransientDB;
#[cfg(all(feature = "web", target_arch = "wasm32"))]
pub use web::{PersistenceState, WebConfig, WebStore};
#[derive(Debug)]
pub struct DataResult<T> {
pub data: Option<T>,
pub removable: Option<Vec<Box<dyn Equivalent>>>,
}
pub trait Equivalent: Any + Debug + Send {
fn equals(&self, other: &dyn Equivalent) -> bool;
fn as_any(&self) -> &dyn Any;
}
pub trait DataStore {
type Output;
fn has_data(&self) -> bool;
fn reset(&mut self);
fn append(&mut self, data: Value) -> Result<()>;
fn fetch(
&mut self,
count: Option<usize>,
max_bytes: Option<usize>,
) -> Result<Option<DataResult<Self::Output>>>;
fn remove(&mut self, data: &[Box<dyn Equivalent>]) -> Result<()>;
}