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>>: Location<'a> {
7 type In<T>;
8 type Out<T>;
9
10 type OutStrongestOrder<InOrder>;
13
14 fn is_demux() -> bool;
15 fn tagged_type() -> Option<syn::Type>;
16}
17
18impl<'a, P1, P2> CanSend<'a, Process<'a, P2>> for Process<'a, P1> {
19 type In<T> = T;
20 type Out<T> = T;
21 type OutStrongestOrder<InOrder> = InOrder;
22
23 fn is_demux() -> bool {
24 false
25 }
26
27 fn tagged_type() -> Option<syn::Type> {
28 None
29 }
30}
31
32impl<'a, P1, C2> CanSend<'a, Cluster<'a, C2>> for Process<'a, P1> {
33 type In<T> = (ClusterId<C2>, T);
34 type Out<T> = T;
35 type OutStrongestOrder<InOrder> = InOrder;
36
37 fn is_demux() -> bool {
38 true
39 }
40
41 fn tagged_type() -> Option<syn::Type> {
42 None
43 }
44}
45
46impl<'a, C1, P2> CanSend<'a, Process<'a, P2>> for Cluster<'a, C1> {
47 type In<T> = T;
48 type Out<T> = (ClusterId<C1>, T);
49 type OutStrongestOrder<InOrder> = NoOrder;
50
51 fn is_demux() -> bool {
52 false
53 }
54
55 fn tagged_type() -> Option<syn::Type> {
56 Some(quote_type::<C1>())
57 }
58}
59
60impl<'a, C1, C2> CanSend<'a, Cluster<'a, C2>> for Cluster<'a, C1> {
61 type In<T> = (ClusterId<C2>, T);
62 type Out<T> = (ClusterId<C1>, T);
63 type OutStrongestOrder<InOrder> = NoOrder;
64
65 fn is_demux() -> bool {
66 true
67 }
68
69 fn tagged_type() -> Option<syn::Type> {
70 Some(quote_type::<C1>())
71 }
72}
73
74impl<'a, P1, E2> CanSend<'a, ExternalProcess<'a, E2>> for Process<'a, P1> {
75 type In<T> = T;
76 type Out<T> = T;
77 type OutStrongestOrder<InOrder> = InOrder;
78
79 fn is_demux() -> bool {
80 false
81 }
82
83 fn tagged_type() -> Option<syn::Type> {
84 None
85 }
86}