hydro_lang/location/
external_process.rs

1use std::marker::PhantomData;
2
3use serde::Serialize;
4use serde::de::DeserializeOwned;
5
6use crate::builder::FlowState;
7use crate::staging_util::Invariant;
8
9pub enum NotMany {}
10pub enum Many {}
11
12pub struct ExternalBytesPort<Many = NotMany> {
13    pub(crate) process_id: usize,
14    pub(crate) port_id: usize,
15    pub(crate) _phantom: PhantomData<Many>,
16}
17
18impl Clone for ExternalBytesPort<Many> {
19    fn clone(&self) -> Self {
20        Self {
21            process_id: self.process_id,
22            port_id: self.port_id,
23            _phantom: Default::default(),
24        }
25    }
26}
27
28pub struct ExternalBincodeSink<Type, Many = NotMany>
29where
30    Type: Serialize,
31{
32    pub(crate) process_id: usize,
33    pub(crate) port_id: usize,
34    pub(crate) _phantom: PhantomData<(Type, Many)>,
35}
36
37impl<T: Serialize> Clone for ExternalBincodeSink<T, Many> {
38    fn clone(&self) -> Self {
39        Self {
40            process_id: self.process_id,
41            port_id: self.port_id,
42            _phantom: Default::default(),
43        }
44    }
45}
46
47pub struct ExternalBincodeBidi<InType, OutType, Many = NotMany> {
48    pub(crate) process_id: usize,
49    pub(crate) port_id: usize,
50    pub(crate) _phantom: PhantomData<(InType, OutType, Many)>,
51}
52
53impl<InT, OutT> Clone for ExternalBincodeBidi<InT, OutT, Many> {
54    fn clone(&self) -> Self {
55        Self {
56            process_id: self.process_id,
57            port_id: self.port_id,
58            _phantom: Default::default(),
59        }
60    }
61}
62
63pub struct ExternalBincodeStream<Type>
64where
65    Type: DeserializeOwned,
66{
67    #[cfg_attr(
68        not(feature = "build"),
69        expect(unused, reason = "unused without feature")
70    )]
71    pub(crate) process_id: usize,
72    #[cfg_attr(
73        not(feature = "build"),
74        expect(unused, reason = "unused without feature")
75    )]
76    pub(crate) port_id: usize,
77    pub(crate) _phantom: PhantomData<Type>,
78}
79
80pub struct External<'a, Tag> {
81    pub(crate) id: usize,
82
83    pub(crate) flow_state: FlowState,
84
85    pub(crate) _phantom: Invariant<'a, Tag>,
86}
87
88impl<P> Clone for External<'_, P> {
89    fn clone(&self) -> Self {
90        External {
91            id: self.id,
92            flow_state: self.flow_state.clone(),
93            _phantom: PhantomData,
94        }
95    }
96}