hydro_lang/location/
process.rs1use std::fmt::{Debug, Formatter};
2use std::marker::PhantomData;
3
4use super::{Location, LocationId};
5use crate::compile::builder::FlowState;
6use crate::location::LocationKey;
7use crate::staging_util::Invariant;
8
9pub struct Process<'a, ProcessTag = ()> {
10 pub(crate) key: LocationKey,
11 pub(crate) flow_state: FlowState,
12 pub(crate) _phantom: Invariant<'a, ProcessTag>,
13}
14
15impl<P> Debug for Process<'_, P> {
16 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
17 write!(f, "Process({})", self.key)
18 }
19}
20
21impl<P> Eq for Process<'_, P> {}
22impl<P> PartialEq for Process<'_, P> {
23 fn eq(&self, other: &Self) -> bool {
24 self.key == other.key && FlowState::ptr_eq(&self.flow_state, &other.flow_state)
25 }
26}
27
28impl<P> Clone for Process<'_, P> {
29 fn clone(&self) -> Self {
30 Process {
31 key: self.key,
32 flow_state: self.flow_state.clone(),
33 _phantom: PhantomData,
34 }
35 }
36}
37
38impl<'a, P> super::dynamic::DynLocation for Process<'a, P> {
39 fn id(&self) -> LocationId {
40 LocationId::Process(self.key)
41 }
42
43 fn flow_state(&self) -> &FlowState {
44 &self.flow_state
45 }
46
47 fn is_top_level() -> bool {
48 true
49 }
50
51 fn multiversioned(&self) -> bool {
52 false }
54}
55
56impl<'a, P> Location<'a> for Process<'a, P> {
57 type Root = Self;
58
59 fn root(&self) -> Self::Root {
60 self.clone()
61 }
62}