hydro_lang/location/
process.rs

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