use core::marker::PhantomData;
use crate::phase::*;
#[must_use = "dropping a PdrSession loses phase tracking — use a transition or terminal"]
pub struct PdrSession<'s, P: Phase> {
_brand: PhantomData<fn(&'s ()) -> &'s ()>,
_phase: PhantomData<P>,
}
impl<'s, P: Phase> PdrSession<'s, P> {
pub(crate) fn new() -> Self {
PdrSession {
_brand: PhantomData,
_phase: PhantomData,
}
}
pub fn phase_name(&self) -> &'static str {
P::NAME
}
}
impl<'s> PdrSession<'s, Init> {
pub fn build_model(self) -> PdrSession<'s, Modeled> {
PdrSession::new()
}
}
impl<'s> PdrSession<'s, Modeled> {
pub fn check_safe(self) -> PdrSession<'s, Safe> {
PdrSession::new()
}
pub fn check_counterexample(self) -> PdrSession<'s, CounterexampleFound> {
PdrSession::new()
}
pub fn check_exhausted(self) -> PdrSession<'s, Exhausted> {
PdrSession::new()
}
}
pub fn with_session<R>(f: impl for<'s> FnOnce(PdrSession<'s, Init>) -> R) -> R {
f(PdrSession::new())
}