hydro_lang/location/
external_process.rs

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