pub(crate) mod canonical;
pub use canonical::Canonical;
pub mod error;
pub use error::Error;
use std::{any, ops};
use crate::{Item, item::IdT};
pub type Result<T> = std::result::Result<T, self::Error>;
pub trait Storage {
type State: crate::State;
fn get<T>(&self, id: IdT<T>) -> self::Result<&Item<T>>
where
T: Storable<Self::State>;
fn get_mut<T>(&mut self, id: IdT<T>) -> self::Result<impl ops::DerefMut<Target = Item<T>>>
where
T: Storable<Self::State>;
fn create<T>(&mut self, value: Item<T>) -> self::Result<()>
where
T: Storable<Self::State>;
fn destroy<T>(&mut self, id: IdT<T>) -> self::Result<Item<T>>
where
T: Storable<Self::State>;
}
#[implied_bounds::implied_bounds]
pub trait Storable<State>: any::Any + serde::Serialize + Sized + Send + Sync
where
State: tagset::TagSetDiscriminant<Self>,
{
}
impl<State, T> Storable<State> for T
where
State: tagset::TagSetDiscriminant<T>,
T: any::Any + serde::Serialize + Sized + Send + Sync,
{
}