dope_sys/table/registry/
state.rs1use std::os::fd;
2
3use o3::{alloc, depot::map::Plan};
4
5use crate::{
6 table,
7 table::{
8 change,
9 registry::{Entry, Failure, Occupied, Vacancy},
10 },
11};
12
13pub trait State<S: table::raw::Slots, E: Entry>: Sized {
14 type Files: table::Files<S, Changes: change::Changes<Id = E::File>>;
15 type Vacancy<'a>: Vacancy<Echo = E::Echo>
16 where
17 Self: 'a;
18 type Occupied<'a>: Occupied<Entry = E>
19 where
20 Self: 'a;
21
22 fn try_new(plan: Plan) -> Result<Self, alloc::Error>;
23 fn try_vacant(&mut self, slot: E) -> Result<Self::Vacancy<'_>, (E, Failure)>;
24 fn occupied(&mut self, echo: E::Echo, family: E::Family) -> Option<Self::Occupied<'_>>;
25 fn take(&mut self, id: E::Id) -> Option<E::Call>;
26 fn remove_fd(
27 &mut self,
28 raw: fd::RawFd,
29 owner: &mut Self::Files,
30 ) -> Result<Option<E::Echo>, change::Index<S::Index>>;
31 fn operation(&self, id: E::Id) -> Option<E::Call>;
32 fn resolve(&self, echo: E::Echo) -> Option<(E::Id, E::Call)>;
33 fn find(&self, echo: E::Echo, family: E::Family) -> Option<E::File>;
34 fn queue_resume(&mut self, id: E::Id);
35 fn pop_resume(&mut self) -> Option<E::Id>;
36 fn can_resume(&self) -> bool;
37 fn files(&self) -> impl Iterator<Item = E::File>;
38 fn clear(&mut self);
39}