Skip to main content

sark_core/decode/
exec.rs

1use crate::decode::state;
2
3#[derive(Debug)]
4pub enum Sync {}
5#[derive(Debug)]
6pub enum Task {}
7#[derive(Debug)]
8pub enum Duplex {}
9#[derive(Debug)]
10pub enum Unsupported {}
11#[derive(Debug)]
12pub enum Mixed {}
13
14/// Application-wide execution shape of selected routes.
15pub trait Set {}
16
17impl Set for Sync {}
18impl Set for Task {}
19impl Set for Duplex {}
20impl Set for Unsupported {}
21impl Set for Mixed {}
22
23impl Kind for Sync {
24    type Open<F: state::Set> = F::SyncOpen;
25    type Finished<F: state::Set> = F::SyncFinished;
26}
27
28impl Kind for Task {
29    type Open<F: state::Set> = F::TaskOpen;
30    type Finished<F: state::Set> = F::TaskFinished;
31}
32
33impl Kind for Duplex {
34    type Open<F: state::Set> = F::DuplexOpen;
35    type Finished<F: state::Set> = F::DuplexFinished;
36}
37
38impl Kind for Unsupported {
39    type Open<F: state::Set> = F::UnsupportedOpen;
40    type Finished<F: state::Set> = F::UnsupportedFinished;
41}
42
43/// Terminal consumer for a route family proven to have one execution kind.
44pub trait Fold<P, F: state::Set, K: Kind>: Sized {
45    type Output;
46
47    fn open<S: state::Slot<P>>(self, slot: S, body: K::Open<F>) -> Self::Output;
48
49    fn finished<S: state::Slot<P>>(self, slot: S, body: K::Finished<F>) -> Self::Output;
50}
51
52/// Uniform execution selected without a runtime execution tag.
53#[doc(hidden)]
54pub trait Kind: Set + Sized {
55    type Open<F: state::Set>;
56    type Finished<F: state::Set>;
57}