Skip to main content

dope_sys/table/token/
codec.rs

1use crate::{
2    io::reactor::complete,
3    table::token::{Close, Context, Decoded, Tuning, frame, host},
4};
5
6type Binding<C, D> = host::Bound<
7    <D as host::Drain>::Echo,
8    <D as host::Drain>::Class,
9    <C as Codec>::Frame,
10    <D as host::Drain>::Flight,
11    <<C as Codec>::Context as host::Context>::Key,
12    <C as Codec>::Tuning,
13>;
14type Frame<C> = Decoded<
15    <<C as Codec>::Context as host::Context>::Key,
16    <<C as Codec>::Context as host::Context>::Returned,
17    <C as Codec>::Frame,
18    <C as Codec>::Tuning,
19>;
20
21/// Native identity construction and classification, before host ownership binding.
22pub trait Codec: complete::raw::Token {
23    type Context: host::Context;
24    type Close<'d>: Close<'d, Context = Self::Context>;
25    type Tuning: Tuning<Slot = <Self::Context as Context>::Slot>;
26    type Frame: frame::Decode<Context = Self::Context, Tuning = Self::Tuning>;
27
28    fn close(control: Self::Close<'_>) -> Self;
29    fn flight(key: <Self::Context as host::Context>::Key) -> Self;
30    fn prepare() -> Self;
31    fn probe(probe: <Self::Context as host::Context>::Probe) -> Self;
32    fn cancel_probe(probe: <Self::Context as host::Context>::Probe) -> Self;
33    fn shutdown() -> Self;
34    fn tuning(control: Self::Tuning) -> Self;
35    fn cancel_key(key: <Self::Context as host::Context>::Key) -> Self;
36    fn cancel_tune(control: Self::Tuning) -> Self;
37    fn cancel(cancel: host::Cancel<<Self::Context as host::Context>::Key, Self::Tuning>) -> Self;
38    fn bind<D>(self, drain: &D) -> Binding<Self, D>
39    where
40        D: host::Drain<
41                Key = <Self::Context as host::Context>::Key,
42                Returned = <Self::Context as host::Context>::Returned,
43            >;
44    fn closed(self) -> Option<<Self::Context as host::Context>::Returned>;
45    fn decode(self) -> Frame<Self>;
46}