dope_sys/probe/cleanup/
mod.rs1use crate::{
2 probe::{State, accept, session},
3 ring::{self, register},
4};
5
6mod release;
7pub use release::Release;
8
9type Stage<S> = State<S, <S as session::Session>::Pending>;
10type Direct<C> = <<C as Cleanup>::Session as session::Empty>::Direct;
11type Occupied<C> = <<C as Cleanup>::Session as session::Empty>::Occupied;
12
13#[derive(Debug, Clone, Copy, Eq, PartialEq)]
15pub enum Failure<S, W> {
16 Storage(S),
17 Wait(W),
18}
19
20pub trait Cleanup: Sized {
22 type Primary: Copy;
23 type Ring: ring::Owner<File = Self::File>;
24 type File: register::Occupied;
25 type Accept: accept::Accept<Ring = Self::Ring, File = Self::File>;
26 type Session: session::Empty<Ring = Self::Ring>;
27 type Error;
28
29 fn raw(ring: Self::Ring, primary: Self::Primary) -> Result<Self::Primary, Self>;
30 fn file(
31 ring: Self::Ring,
32 primary: Self::Primary,
33 file: Self::File,
34 ) -> Result<Self::Primary, Self>;
35 fn accept(
36 state: Self::Accept,
37 primary: Self::Primary,
38 file: Self::File,
39 ) -> Result<Self::Primary, Self>;
40 fn session(state: Self::Session, primary: Self::Primary) -> Result<Self::Primary, Self>;
41 fn receive(state: Stage<Occupied<Self>>, primary: Self::Primary)
42 -> Result<Self::Primary, Self>;
43 fn socket(state: Direct<Self>, primary: Self::Primary) -> Result<Self::Primary, Self>;
44 fn option(state: Stage<Direct<Self>>, primary: Self::Primary) -> Result<Self::Primary, Self>;
45 fn primary(&self) -> Self::Primary;
46 fn failure(&self) -> Self::Error;
47 fn try_close(self, report: impl FnMut(Self::Error)) -> Result<Self::Primary, Self>;
48}
49
50#[derive(Debug)]
52pub enum Rejection<C, R> {
53 Cleanup(C),
54 Release(R),
55}