use crate::{
io::{Close, 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: Close<State: Retry + memory::Failure> + Sized {
type Layout: memory::raw::Canary;
type Index: Copy;
type Error: provided::Failure<Cleanup = Self::State>;
type Buffer<const GROUP: u16>;
fn new() -> Result<Self, Self::Error>;
fn into_buffer<const GROUP: u16>(self) -> Self::Buffer<GROUP>;
unsafe fn option(&mut self) -> &libc::c_int;
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>>;
}