ferrite_session/internal/base/context/
traits.rs1use crate::internal::functional::nat::Nat;
2
3pub struct Empty;
4
5pub trait SealedContext {}
6
7pub trait Context: SealedContext + Send + 'static
8{
9 type Endpoints: Sized + Send;
10
11 type Length: Nat;
12}
13
14pub trait SealedEmptyContext {}
15
16pub trait EmptyContext: SealedEmptyContext + Context
17{
18 fn empty_values() -> <Self as Context>::Endpoints;
19}
20
21pub trait AppendContext<R>: Context
22where
23 R: Context,
24{
25 type Appended: Context;
26
27 fn append_context(
28 channels1: <Self as Context>::Endpoints,
29 channels2: <R as Context>::Endpoints,
30 ) -> <Self::Appended as Context>::Endpoints;
31
32 fn split_context(
33 channels: <Self::Appended as Context>::Endpoints
34 ) -> (<Self as Context>::Endpoints, <R as Context>::Endpoints);
35}
36
37pub trait SealedSlot {}
38
39pub trait Slot: SealedSlot + Send + 'static
40{
41 type Endpoint: Send;
42}
43
44pub trait ContextLens<C, A1, A2>: Send + 'static
45where
46 C: Context,
47 A1: Slot,
48 A2: Slot,
49{
50 type Deleted: Context;
51
52 type Target: Context;
53
54 fn extract_source(
55 channels: C::Endpoints
56 ) -> (A1::Endpoint, <Self::Deleted as Context>::Endpoints);
57
58 fn insert_target(
59 receiver: A2::Endpoint,
60 channels: <Self::Deleted as Context>::Endpoints,
61 ) -> <Self::Target as Context>::Endpoints;
62}