use std::fmt::{Debug, Formatter};
use std::marker::PhantomData;
use super::{Location, LocationId};
use crate::compile::builder::FlowState;
use crate::location::LocationKey;
use crate::staging_util::Invariant;
pub struct Process<'a, ProcessTag = ()> {
pub(crate) key: LocationKey,
pub(crate) flow_state: FlowState,
pub(crate) _phantom: Invariant<'a, ProcessTag>,
}
impl<P> Debug for Process<'_, P> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "Process({})", self.key)
}
}
impl<P> Eq for Process<'_, P> {}
impl<P> PartialEq for Process<'_, P> {
fn eq(&self, other: &Self) -> bool {
self.key == other.key && FlowState::ptr_eq(&self.flow_state, &other.flow_state)
}
}
impl<P> Clone for Process<'_, P> {
fn clone(&self) -> Self {
Process {
key: self.key,
flow_state: self.flow_state.clone(),
_phantom: PhantomData,
}
}
}
impl<'a, P> super::dynamic::DynLocation for Process<'a, P> {
fn id(&self) -> LocationId {
LocationId::Process(self.key)
}
fn flow_state(&self) -> &FlowState {
&self.flow_state
}
fn is_top_level() -> bool {
true
}
fn multiversioned(&self) -> bool {
false }
}
impl<'a, P> Location<'a> for Process<'a, P> {
type Root = Self;
fn root(&self) -> Self::Root {
self.clone()
}
}