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