use crate::{
io::Retry,
memory,
memory::buffer::{canary::Failure, provided},
};
type Extent<S> = <<S as Storage>::Layout as memory::raw::Receive>::Extent;
type Inspection<S, E> = Failure<
<S as Storage>::Index,
<Extent<S> as memory::raw::Extent>::Length,
<Extent<S> as memory::raw::Extent>::Capacity,
E,
>;
pub trait Storage: Sized {
type Layout: memory::raw::Canary;
type Index: Copy;
type State: Retry<Owner: From<Self>> + memory::Failure;
type Error: provided::Failure<Cleanup = Self::State>;
fn new() -> Result<Self, Self::Error>;
unsafe fn inspect<E>(
&mut self,
index: Self::Index,
len: <<Self::Layout as memory::raw::Receive>::Extent as memory::raw::Extent>::Length,
check: impl FnOnce(&[u8]) -> Result<(), E>,
) -> Result<(), Inspection<Self, E>>;
}