hydro_lang/location/
process.rs1use std::fmt::{Debug, Formatter};
14use std::marker::PhantomData;
15
16use super::{Location, LocationId};
17use crate::compile::builder::FlowState;
18use crate::location::{LocationKey, TopLevel};
19use crate::staging_util::Invariant;
20
21pub struct Process<'a, ProcessTag = ()> {
38 pub(crate) key: LocationKey,
39 pub(crate) flow_state: FlowState,
40 pub(crate) _phantom: Invariant<'a, ProcessTag>,
41}
42
43impl<P> Debug for Process<'_, P> {
44 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
45 write!(f, "Process({})", self.key)
46 }
47}
48
49impl<P> Eq for Process<'_, P> {}
50impl<P> PartialEq for Process<'_, P> {
51 fn eq(&self, other: &Self) -> bool {
52 self.key == other.key && FlowState::ptr_eq(&self.flow_state, &other.flow_state)
53 }
54}
55
56impl<P> Clone for Process<'_, P> {
57 fn clone(&self) -> Self {
58 Process {
59 key: self.key,
60 flow_state: self.flow_state.clone(),
61 _phantom: PhantomData,
62 }
63 }
64}
65
66impl<'a, P> super::dynamic::DynLocation for Process<'a, P> {
67 fn dyn_id(&self) -> LocationId {
68 LocationId::Process(self.key)
69 }
70
71 fn flow_state(&self) -> &FlowState {
72 &self.flow_state
73 }
74
75 fn is_top_level() -> bool {
76 true
77 }
78
79 fn multiversioned(&self) -> bool {
80 false }
82
83 fn cluster_consistency() -> Option<super::dynamic::ClusterConsistency> {
84 None
85 }
86}
87
88impl<'a, P> Location<'a> for Process<'a, P> {
89 type Root = Self;
90
91 type DropConsistency = Self;
92
93 fn consistency() -> Option<super::dynamic::ClusterConsistency> {
94 None
95 }
96
97 fn root(&self) -> Self::Root {
98 self.clone()
99 }
100
101 fn drop_consistency(&self) -> Self::DropConsistency {
102 self.clone()
103 }
104
105 fn from_drop_consistency(l2: Self::DropConsistency) -> Self {
106 l2
107 }
108}
109
110impl<'a, P> TopLevel<'a> for Process<'a, P> {}