hydro_lang/location/
can_send.rs

1use stageleft::quote_type;
2
3use super::{Cluster, ClusterId, ExternalProcess, Location, Process};
4use crate::stream::NoOrder;
5
6pub trait CanSend<'a, To>: Location<'a>
7where
8    To: Location<'a>,
9{
10    type In<Type>;
11    type Out<Type>;
12
13    /// Given the ordering guarantees of the input, determines the strongest possible
14    /// ordering guarantees of the output.
15    type OutStrongestOrder<InOrder>;
16
17    fn is_demux() -> bool;
18    fn tagged_type() -> Option<syn::Type>;
19}
20
21impl<'a, P1, P2> CanSend<'a, Process<'a, P2>> for Process<'a, P1> {
22    type In<T> = T;
23    type Out<T> = T;
24    type OutStrongestOrder<InOrder> = InOrder;
25
26    fn is_demux() -> bool {
27        false
28    }
29
30    fn tagged_type() -> Option<syn::Type> {
31        None
32    }
33}
34
35impl<'a, P1, C2> CanSend<'a, Cluster<'a, C2>> for Process<'a, P1> {
36    type In<T> = (ClusterId<C2>, T);
37    type Out<T> = T;
38    type OutStrongestOrder<InOrder> = InOrder;
39
40    fn is_demux() -> bool {
41        true
42    }
43
44    fn tagged_type() -> Option<syn::Type> {
45        None
46    }
47}
48
49impl<'a, C1, P2> CanSend<'a, Process<'a, P2>> for Cluster<'a, C1> {
50    type In<T> = T;
51    type Out<T> = (ClusterId<C1>, T);
52    type OutStrongestOrder<InOrder> = NoOrder;
53
54    fn is_demux() -> bool {
55        false
56    }
57
58    fn tagged_type() -> Option<syn::Type> {
59        Some(quote_type::<C1>())
60    }
61}
62
63impl<'a, C1, C2> CanSend<'a, Cluster<'a, C2>> for Cluster<'a, C1> {
64    type In<T> = (ClusterId<C2>, T);
65    type Out<T> = (ClusterId<C1>, T);
66    type OutStrongestOrder<InOrder> = NoOrder;
67
68    fn is_demux() -> bool {
69        true
70    }
71
72    fn tagged_type() -> Option<syn::Type> {
73        Some(quote_type::<C1>())
74    }
75}
76
77impl<'a, P1, E2> CanSend<'a, ExternalProcess<'a, E2>> for Process<'a, P1> {
78    type In<T> = T;
79    type Out<T> = T;
80    type OutStrongestOrder<InOrder> = InOrder;
81
82    fn is_demux() -> bool {
83        false
84    }
85
86    fn tagged_type() -> Option<syn::Type> {
87        None
88    }
89}