dope_sys/memory/buffer/canary/
raw.rs1use crate::{
2 io::{Close, Retry},
3 memory,
4 memory::buffer::{canary::Failure, provided},
5};
6
7type Extent<S> = <<S as Storage>::Layout as memory::raw::Receive>::Extent;
8type Inspection<S, E> = Failure<
9 <S as Storage>::Index,
10 <Extent<S> as memory::raw::Extent>::Length,
11 <Extent<S> as memory::raw::Extent>::Capacity,
12 E,
13>;
14
15pub trait Storage: Close<State: Retry + memory::Failure> + Sized {
17 type Layout: memory::raw::Canary;
18 type Index: Copy;
19 type Error: provided::Failure<Cleanup = Self::State>;
20 type Buffer<const GROUP: u16>;
21
22 fn new() -> Result<Self, Self::Error>;
23 fn into_buffer<const GROUP: u16>(self) -> Self::Buffer<GROUP>;
24
25 unsafe fn option(&mut self) -> &libc::c_int;
28
29 unsafe fn inspect<E>(
32 &mut self,
33 index: Self::Index,
34 len: <<Self::Layout as memory::raw::Receive>::Extent as memory::raw::Extent>::Length,
35 check: impl FnOnce(&[u8]) -> Result<(), E>,
36 ) -> Result<(), Inspection<Self, E>>;
37}