1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use crate::internal::functional::nat::Nat;

pub struct Empty;

pub trait SealedContext {}

pub trait Context: SealedContext + Send + 'static
{
  type Endpoints: Sized + Send;

  type Length: Nat;
}

pub trait SealedEmptyContext {}

pub trait EmptyContext: SealedEmptyContext + Context
{
  fn empty_values() -> <Self as Context>::Endpoints;
}

pub trait AppendContext<R>: Context
where
  R: Context,
{
  type Appended: Context;

  fn append_context(
    channels1: <Self as Context>::Endpoints,
    channels2: <R as Context>::Endpoints,
  ) -> <Self::Appended as Context>::Endpoints;

  fn split_context(
    channels: <Self::Appended as Context>::Endpoints
  ) -> (<Self as Context>::Endpoints, <R as Context>::Endpoints);
}

pub trait SealedSlot {}

pub trait Slot: SealedSlot + Send + 'static
{
  type Endpoint: Send;
}

pub trait ContextLens<C, A1, A2>: Send + 'static
where
  C: Context,
  A1: Slot,
  A2: Slot,
{
  type Deleted: Context;

  type Target: Context;

  fn extract_source(
    channels: C::Endpoints
  ) -> (A1::Endpoint, <Self::Deleted as Context>::Endpoints);

  fn insert_target(
    receiver: A2::Endpoint,
    channels: <Self::Deleted as Context>::Endpoints,
  ) -> <Self::Target as Context>::Endpoints;
}