use crate::enums::MeasurementUnit;
use crate::enums::RewriteRule;
use crate::HostTypes;
pub trait Derivation<H: HostTypes> {
type Term: crate::kernel::schema::Term<H>;
fn original_term(&self) -> &Self::Term;
fn canonical_term(&self) -> &Self::Term;
type Datum: crate::kernel::schema::Datum<H>;
fn result(&self) -> &Self::Datum;
type RewriteStep: RewriteStep<H>;
fn step(&self) -> &[Self::RewriteStep];
type TermMetrics: TermMetrics<H>;
fn term_metrics(&self) -> &Self::TermMetrics;
}
pub trait DerivationStep<H: HostTypes> {}
pub trait RewriteStep<H: HostTypes>: DerivationStep<H> {
type Term: crate::kernel::schema::Term<H>;
fn from(&self) -> &Self::Term;
fn to(&self) -> &Self::Term;
fn has_rewrite_rule(&self) -> RewriteRule;
}
pub trait RefinementStep<H: HostTypes>: DerivationStep<H> {
type TypeDefinition: crate::user::type_::TypeDefinition<H>;
fn previous_type(&self) -> &Self::TypeDefinition;
type Constraint: crate::user::type_::Constraint<H>;
fn applied_constraint(&self) -> &Self::Constraint;
fn refined_type(&self) -> &Self::TypeDefinition;
fn sites_closed(&self) -> u64;
}
pub trait TermMetrics<H: HostTypes> {
fn step_count(&self) -> u64;
fn term_size(&self) -> u64;
}
pub trait SynthesisStep<H: HostTypes> {
fn step_index(&self) -> u64;
type Constraint: crate::user::type_::Constraint<H>;
fn added_constraint(&self) -> &Self::Constraint;
type SynthesisSignature: crate::bridge::observable::SynthesisSignature<H>;
fn signature_before(&self) -> &Self::SynthesisSignature;
fn signature_after(&self) -> &Self::SynthesisSignature;
}
pub trait SynthesisCheckpoint<H: HostTypes> {
type SynthesisStep: SynthesisStep<H>;
fn checkpoint_step(&self) -> &Self::SynthesisStep;
type ConstraintSearchState: crate::bridge::resolver::ConstraintSearchState<H>;
fn checkpoint_state(&self) -> &Self::ConstraintSearchState;
}
pub trait InhabitanceStep<H: HostTypes>: SynthesisStep<H> {
type ConstraintSearchState: crate::bridge::resolver::ConstraintSearchState<H>;
fn prior_state(&self) -> &Self::ConstraintSearchState;
fn successor_state(&self) -> &Self::ConstraintSearchState;
type DispatchRule: crate::kernel::predicate::DispatchRule<H>;
fn rule(&self) -> &Self::DispatchRule;
}
pub trait InhabitanceCheckpoint<H: HostTypes>: SynthesisCheckpoint<H> {
fn checkpoint_index(&self) -> i64;
}
pub trait DerivationDepthObservable<H: HostTypes>:
crate::bridge::observable::Observable<H>
{
}
pub trait DerivationTrace<H: HostTypes> {
fn trace_event_count(&self) -> u64;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullDerivation<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullDerivation<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullDerivation<H> {
pub const ABSENT: NullDerivation<H> = NullDerivation {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> Derivation<H> for NullDerivation<H> {
type Term = crate::kernel::schema::NullTerm<H>;
fn original_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn canonical_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
type Datum = crate::kernel::schema::NullDatum<H>;
fn result(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
type RewriteStep = NullRewriteStep<H>;
fn step(&self) -> &[Self::RewriteStep] {
&[]
}
type TermMetrics = NullTermMetrics<H>;
fn term_metrics(&self) -> &Self::TermMetrics {
&<NullTermMetrics<H>>::ABSENT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullDerivationStep<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullDerivationStep<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullDerivationStep<H> {
pub const ABSENT: NullDerivationStep<H> = NullDerivationStep {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> DerivationStep<H> for NullDerivationStep<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullRewriteStep<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullRewriteStep<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullRewriteStep<H> {
pub const ABSENT: NullRewriteStep<H> = NullRewriteStep {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> DerivationStep<H> for NullRewriteStep<H> {}
impl<H: HostTypes> RewriteStep<H> for NullRewriteStep<H> {
type Term = crate::kernel::schema::NullTerm<H>;
fn from(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn to(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn has_rewrite_rule(&self) -> RewriteRule {
<RewriteRule>::default()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullRefinementStep<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullRefinementStep<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullRefinementStep<H> {
pub const ABSENT: NullRefinementStep<H> = NullRefinementStep {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> DerivationStep<H> for NullRefinementStep<H> {}
impl<H: HostTypes> RefinementStep<H> for NullRefinementStep<H> {
type TypeDefinition = crate::user::type_::NullTypeDefinition<H>;
fn previous_type(&self) -> &Self::TypeDefinition {
&<crate::user::type_::NullTypeDefinition<H>>::ABSENT
}
type Constraint = crate::user::type_::NullConstraint<H>;
fn applied_constraint(&self) -> &Self::Constraint {
&<crate::user::type_::NullConstraint<H>>::ABSENT
}
fn refined_type(&self) -> &Self::TypeDefinition {
&<crate::user::type_::NullTypeDefinition<H>>::ABSENT
}
fn sites_closed(&self) -> u64 {
0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullTermMetrics<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullTermMetrics<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullTermMetrics<H> {
pub const ABSENT: NullTermMetrics<H> = NullTermMetrics {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> TermMetrics<H> for NullTermMetrics<H> {
fn step_count(&self) -> u64 {
0
}
fn term_size(&self) -> u64 {
0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullSynthesisStep<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullSynthesisStep<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullSynthesisStep<H> {
pub const ABSENT: NullSynthesisStep<H> = NullSynthesisStep {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> SynthesisStep<H> for NullSynthesisStep<H> {
fn step_index(&self) -> u64 {
0
}
type Constraint = crate::user::type_::NullConstraint<H>;
fn added_constraint(&self) -> &Self::Constraint {
&<crate::user::type_::NullConstraint<H>>::ABSENT
}
type SynthesisSignature = crate::bridge::observable::NullSynthesisSignature<H>;
fn signature_before(&self) -> &Self::SynthesisSignature {
&<crate::bridge::observable::NullSynthesisSignature<H>>::ABSENT
}
fn signature_after(&self) -> &Self::SynthesisSignature {
&<crate::bridge::observable::NullSynthesisSignature<H>>::ABSENT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullSynthesisCheckpoint<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullSynthesisCheckpoint<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullSynthesisCheckpoint<H> {
pub const ABSENT: NullSynthesisCheckpoint<H> = NullSynthesisCheckpoint {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> SynthesisCheckpoint<H> for NullSynthesisCheckpoint<H> {
type SynthesisStep = NullSynthesisStep<H>;
fn checkpoint_step(&self) -> &Self::SynthesisStep {
&<NullSynthesisStep<H>>::ABSENT
}
type ConstraintSearchState = crate::bridge::resolver::NullConstraintSearchState<H>;
fn checkpoint_state(&self) -> &Self::ConstraintSearchState {
&<crate::bridge::resolver::NullConstraintSearchState<H>>::ABSENT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullInhabitanceStep<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullInhabitanceStep<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullInhabitanceStep<H> {
pub const ABSENT: NullInhabitanceStep<H> = NullInhabitanceStep {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> SynthesisStep<H> for NullInhabitanceStep<H> {
fn step_index(&self) -> u64 {
0
}
type Constraint = crate::user::type_::NullConstraint<H>;
fn added_constraint(&self) -> &Self::Constraint {
&<crate::user::type_::NullConstraint<H>>::ABSENT
}
type SynthesisSignature = crate::bridge::observable::NullSynthesisSignature<H>;
fn signature_before(&self) -> &Self::SynthesisSignature {
&<crate::bridge::observable::NullSynthesisSignature<H>>::ABSENT
}
fn signature_after(&self) -> &Self::SynthesisSignature {
&<crate::bridge::observable::NullSynthesisSignature<H>>::ABSENT
}
}
impl<H: HostTypes> InhabitanceStep<H> for NullInhabitanceStep<H> {
type ConstraintSearchState = crate::bridge::resolver::NullConstraintSearchState<H>;
fn prior_state(&self) -> &Self::ConstraintSearchState {
&<crate::bridge::resolver::NullConstraintSearchState<H>>::ABSENT
}
fn successor_state(&self) -> &Self::ConstraintSearchState {
&<crate::bridge::resolver::NullConstraintSearchState<H>>::ABSENT
}
type DispatchRule = crate::kernel::predicate::NullDispatchRule<H>;
fn rule(&self) -> &Self::DispatchRule {
&<crate::kernel::predicate::NullDispatchRule<H>>::ABSENT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullInhabitanceCheckpoint<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullInhabitanceCheckpoint<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullInhabitanceCheckpoint<H> {
pub const ABSENT: NullInhabitanceCheckpoint<H> = NullInhabitanceCheckpoint {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> SynthesisCheckpoint<H> for NullInhabitanceCheckpoint<H> {
type SynthesisStep = NullSynthesisStep<H>;
fn checkpoint_step(&self) -> &Self::SynthesisStep {
&<NullSynthesisStep<H>>::ABSENT
}
type ConstraintSearchState = crate::bridge::resolver::NullConstraintSearchState<H>;
fn checkpoint_state(&self) -> &Self::ConstraintSearchState {
&<crate::bridge::resolver::NullConstraintSearchState<H>>::ABSENT
}
}
impl<H: HostTypes> InhabitanceCheckpoint<H> for NullInhabitanceCheckpoint<H> {
fn checkpoint_index(&self) -> i64 {
0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullDerivationDepthObservable<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullDerivationDepthObservable<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullDerivationDepthObservable<H> {
pub const ABSENT: NullDerivationDepthObservable<H> = NullDerivationDepthObservable {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> crate::bridge::observable::Observable<H> for NullDerivationDepthObservable<H> {
fn value(&self) -> H::Decimal {
H::EMPTY_DECIMAL
}
fn source(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
fn target(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
fn has_unit(&self) -> MeasurementUnit {
<MeasurementUnit>::default()
}
}
impl<H: HostTypes> DerivationDepthObservable<H> for NullDerivationDepthObservable<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullDerivationTrace<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullDerivationTrace<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullDerivationTrace<H> {
pub const ABSENT: NullDerivationTrace<H> = NullDerivationTrace {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> DerivationTrace<H> for NullDerivationTrace<H> {
fn trace_event_count(&self) -> u64 {
0
}
}
#[derive(Debug)]
pub struct DerivationHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for DerivationHandle<H> {}
impl<H: HostTypes> Clone for DerivationHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for DerivationHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for DerivationHandle<H> {}
impl<H: HostTypes> core::hash::Hash for DerivationHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> DerivationHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait DerivationResolver<H: HostTypes> {
fn resolve(&self, handle: DerivationHandle<H>) -> Option<DerivationRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct DerivationRecord<H: HostTypes> {
pub original_term_handle: crate::kernel::schema::TermHandle<H>,
pub canonical_term_handle: crate::kernel::schema::TermHandle<H>,
pub result_handle: crate::kernel::schema::DatumHandle<H>,
pub term_metrics_handle: TermMetricsHandle<H>,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedDerivation<'r, R: DerivationResolver<H>, H: HostTypes> {
handle: DerivationHandle<H>,
resolver: &'r R,
record: Option<DerivationRecord<H>>,
}
impl<'r, R: DerivationResolver<H>, H: HostTypes> ResolvedDerivation<'r, R, H> {
#[inline]
pub fn new(handle: DerivationHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> DerivationHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&DerivationRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: DerivationResolver<H>, H: HostTypes> Derivation<H> for ResolvedDerivation<'r, R, H> {
type Term = crate::kernel::schema::NullTerm<H>;
fn original_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn canonical_term(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
type Datum = crate::kernel::schema::NullDatum<H>;
fn result(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
type RewriteStep = NullRewriteStep<H>;
fn step(&self) -> &[Self::RewriteStep] {
&[]
}
type TermMetrics = NullTermMetrics<H>;
fn term_metrics(&self) -> &Self::TermMetrics {
&<NullTermMetrics<H>>::ABSENT
}
}
impl<'r, R: DerivationResolver<H>, H: HostTypes> ResolvedDerivation<'r, R, H> {
#[inline]
pub fn resolve_original_term<'r2, R2: crate::kernel::schema::TermResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::schema::ResolvedTerm<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::schema::ResolvedTerm::new(
record.original_term_handle,
r,
))
}
#[inline]
pub fn resolve_canonical_term<'r2, R2: crate::kernel::schema::TermResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::schema::ResolvedTerm<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::schema::ResolvedTerm::new(
record.canonical_term_handle,
r,
))
}
#[inline]
pub fn resolve_result<'r2, R2: crate::kernel::schema::DatumResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::schema::ResolvedDatum<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::schema::ResolvedDatum::new(
record.result_handle,
r,
))
}
#[inline]
pub fn resolve_term_metrics<'r2, R2: TermMetricsResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedTermMetrics<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedTermMetrics::new(record.term_metrics_handle, r))
}
}
#[derive(Debug)]
pub struct DerivationStepHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for DerivationStepHandle<H> {}
impl<H: HostTypes> Clone for DerivationStepHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for DerivationStepHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for DerivationStepHandle<H> {}
impl<H: HostTypes> core::hash::Hash for DerivationStepHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> DerivationStepHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait DerivationStepResolver<H: HostTypes> {
fn resolve(&self, handle: DerivationStepHandle<H>) -> Option<DerivationStepRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct DerivationStepRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedDerivationStep<'r, R: DerivationStepResolver<H>, H: HostTypes> {
handle: DerivationStepHandle<H>,
resolver: &'r R,
record: Option<DerivationStepRecord<H>>,
}
impl<'r, R: DerivationStepResolver<H>, H: HostTypes> ResolvedDerivationStep<'r, R, H> {
#[inline]
pub fn new(handle: DerivationStepHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> DerivationStepHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&DerivationStepRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: DerivationStepResolver<H>, H: HostTypes> DerivationStep<H>
for ResolvedDerivationStep<'r, R, H>
{
}
#[derive(Debug)]
pub struct RewriteStepHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for RewriteStepHandle<H> {}
impl<H: HostTypes> Clone for RewriteStepHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for RewriteStepHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for RewriteStepHandle<H> {}
impl<H: HostTypes> core::hash::Hash for RewriteStepHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> RewriteStepHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait RewriteStepResolver<H: HostTypes> {
fn resolve(&self, handle: RewriteStepHandle<H>) -> Option<RewriteStepRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct RewriteStepRecord<H: HostTypes> {
pub from_handle: crate::kernel::schema::TermHandle<H>,
pub to_handle: crate::kernel::schema::TermHandle<H>,
pub has_rewrite_rule: RewriteRule,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedRewriteStep<'r, R: RewriteStepResolver<H>, H: HostTypes> {
handle: RewriteStepHandle<H>,
resolver: &'r R,
record: Option<RewriteStepRecord<H>>,
}
impl<'r, R: RewriteStepResolver<H>, H: HostTypes> ResolvedRewriteStep<'r, R, H> {
#[inline]
pub fn new(handle: RewriteStepHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> RewriteStepHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&RewriteStepRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: RewriteStepResolver<H>, H: HostTypes> DerivationStep<H>
for ResolvedRewriteStep<'r, R, H>
{
}
impl<'r, R: RewriteStepResolver<H>, H: HostTypes> RewriteStep<H> for ResolvedRewriteStep<'r, R, H> {
type Term = crate::kernel::schema::NullTerm<H>;
fn from(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn to(&self) -> &Self::Term {
&<crate::kernel::schema::NullTerm<H>>::ABSENT
}
fn has_rewrite_rule(&self) -> RewriteRule {
match &self.record {
Some(r) => r.has_rewrite_rule,
None => <RewriteRule>::default(),
}
}
}
impl<'r, R: RewriteStepResolver<H>, H: HostTypes> ResolvedRewriteStep<'r, R, H> {
#[inline]
pub fn resolve_from<'r2, R2: crate::kernel::schema::TermResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::schema::ResolvedTerm<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::schema::ResolvedTerm::new(
record.from_handle,
r,
))
}
#[inline]
pub fn resolve_to<'r2, R2: crate::kernel::schema::TermResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::schema::ResolvedTerm<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::schema::ResolvedTerm::new(
record.to_handle,
r,
))
}
}
#[derive(Debug)]
pub struct RefinementStepHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for RefinementStepHandle<H> {}
impl<H: HostTypes> Clone for RefinementStepHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for RefinementStepHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for RefinementStepHandle<H> {}
impl<H: HostTypes> core::hash::Hash for RefinementStepHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> RefinementStepHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait RefinementStepResolver<H: HostTypes> {
fn resolve(&self, handle: RefinementStepHandle<H>) -> Option<RefinementStepRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct RefinementStepRecord<H: HostTypes> {
pub previous_type_handle: crate::user::type_::TypeDefinitionHandle<H>,
pub applied_constraint_handle: crate::user::type_::ConstraintHandle<H>,
pub refined_type_handle: crate::user::type_::TypeDefinitionHandle<H>,
pub sites_closed: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedRefinementStep<'r, R: RefinementStepResolver<H>, H: HostTypes> {
handle: RefinementStepHandle<H>,
resolver: &'r R,
record: Option<RefinementStepRecord<H>>,
}
impl<'r, R: RefinementStepResolver<H>, H: HostTypes> ResolvedRefinementStep<'r, R, H> {
#[inline]
pub fn new(handle: RefinementStepHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> RefinementStepHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&RefinementStepRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: RefinementStepResolver<H>, H: HostTypes> DerivationStep<H>
for ResolvedRefinementStep<'r, R, H>
{
}
impl<'r, R: RefinementStepResolver<H>, H: HostTypes> RefinementStep<H>
for ResolvedRefinementStep<'r, R, H>
{
type TypeDefinition = crate::user::type_::NullTypeDefinition<H>;
fn previous_type(&self) -> &Self::TypeDefinition {
&<crate::user::type_::NullTypeDefinition<H>>::ABSENT
}
type Constraint = crate::user::type_::NullConstraint<H>;
fn applied_constraint(&self) -> &Self::Constraint {
&<crate::user::type_::NullConstraint<H>>::ABSENT
}
fn refined_type(&self) -> &Self::TypeDefinition {
&<crate::user::type_::NullTypeDefinition<H>>::ABSENT
}
fn sites_closed(&self) -> u64 {
match &self.record {
Some(r) => r.sites_closed,
None => 0,
}
}
}
impl<'r, R: RefinementStepResolver<H>, H: HostTypes> ResolvedRefinementStep<'r, R, H> {
#[inline]
pub fn resolve_previous_type<'r2, R2: crate::user::type_::TypeDefinitionResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::user::type_::ResolvedTypeDefinition<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::user::type_::ResolvedTypeDefinition::new(
record.previous_type_handle,
r,
))
}
#[inline]
pub fn resolve_applied_constraint<'r2, R2: crate::user::type_::ConstraintResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::user::type_::ResolvedConstraint<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::user::type_::ResolvedConstraint::new(
record.applied_constraint_handle,
r,
))
}
#[inline]
pub fn resolve_refined_type<'r2, R2: crate::user::type_::TypeDefinitionResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::user::type_::ResolvedTypeDefinition<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::user::type_::ResolvedTypeDefinition::new(
record.refined_type_handle,
r,
))
}
}
#[derive(Debug)]
pub struct TermMetricsHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for TermMetricsHandle<H> {}
impl<H: HostTypes> Clone for TermMetricsHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for TermMetricsHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for TermMetricsHandle<H> {}
impl<H: HostTypes> core::hash::Hash for TermMetricsHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> TermMetricsHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait TermMetricsResolver<H: HostTypes> {
fn resolve(&self, handle: TermMetricsHandle<H>) -> Option<TermMetricsRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct TermMetricsRecord<H: HostTypes> {
pub step_count: u64,
pub term_size: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedTermMetrics<'r, R: TermMetricsResolver<H>, H: HostTypes> {
handle: TermMetricsHandle<H>,
resolver: &'r R,
record: Option<TermMetricsRecord<H>>,
}
impl<'r, R: TermMetricsResolver<H>, H: HostTypes> ResolvedTermMetrics<'r, R, H> {
#[inline]
pub fn new(handle: TermMetricsHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> TermMetricsHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&TermMetricsRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: TermMetricsResolver<H>, H: HostTypes> TermMetrics<H> for ResolvedTermMetrics<'r, R, H> {
fn step_count(&self) -> u64 {
match &self.record {
Some(r) => r.step_count,
None => 0,
}
}
fn term_size(&self) -> u64 {
match &self.record {
Some(r) => r.term_size,
None => 0,
}
}
}
#[derive(Debug)]
pub struct SynthesisStepHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for SynthesisStepHandle<H> {}
impl<H: HostTypes> Clone for SynthesisStepHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for SynthesisStepHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for SynthesisStepHandle<H> {}
impl<H: HostTypes> core::hash::Hash for SynthesisStepHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> SynthesisStepHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait SynthesisStepResolver<H: HostTypes> {
fn resolve(&self, handle: SynthesisStepHandle<H>) -> Option<SynthesisStepRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct SynthesisStepRecord<H: HostTypes> {
pub step_index: u64,
pub added_constraint_handle: crate::user::type_::ConstraintHandle<H>,
pub signature_before_handle: crate::bridge::observable::SynthesisSignatureHandle<H>,
pub signature_after_handle: crate::bridge::observable::SynthesisSignatureHandle<H>,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedSynthesisStep<'r, R: SynthesisStepResolver<H>, H: HostTypes> {
handle: SynthesisStepHandle<H>,
resolver: &'r R,
record: Option<SynthesisStepRecord<H>>,
}
impl<'r, R: SynthesisStepResolver<H>, H: HostTypes> ResolvedSynthesisStep<'r, R, H> {
#[inline]
pub fn new(handle: SynthesisStepHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> SynthesisStepHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&SynthesisStepRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: SynthesisStepResolver<H>, H: HostTypes> SynthesisStep<H>
for ResolvedSynthesisStep<'r, R, H>
{
fn step_index(&self) -> u64 {
match &self.record {
Some(r) => r.step_index,
None => 0,
}
}
type Constraint = crate::user::type_::NullConstraint<H>;
fn added_constraint(&self) -> &Self::Constraint {
&<crate::user::type_::NullConstraint<H>>::ABSENT
}
type SynthesisSignature = crate::bridge::observable::NullSynthesisSignature<H>;
fn signature_before(&self) -> &Self::SynthesisSignature {
&<crate::bridge::observable::NullSynthesisSignature<H>>::ABSENT
}
fn signature_after(&self) -> &Self::SynthesisSignature {
&<crate::bridge::observable::NullSynthesisSignature<H>>::ABSENT
}
}
impl<'r, R: SynthesisStepResolver<H>, H: HostTypes> ResolvedSynthesisStep<'r, R, H> {
#[inline]
pub fn resolve_added_constraint<'r2, R2: crate::user::type_::ConstraintResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::user::type_::ResolvedConstraint<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::user::type_::ResolvedConstraint::new(
record.added_constraint_handle,
r,
))
}
#[inline]
pub fn resolve_signature_before<
'r2,
R2: crate::bridge::observable::SynthesisSignatureResolver<H>,
>(
&self,
r: &'r2 R2,
) -> Option<crate::bridge::observable::ResolvedSynthesisSignature<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::bridge::observable::ResolvedSynthesisSignature::new(
record.signature_before_handle,
r,
))
}
#[inline]
pub fn resolve_signature_after<
'r2,
R2: crate::bridge::observable::SynthesisSignatureResolver<H>,
>(
&self,
r: &'r2 R2,
) -> Option<crate::bridge::observable::ResolvedSynthesisSignature<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::bridge::observable::ResolvedSynthesisSignature::new(
record.signature_after_handle,
r,
))
}
}
#[derive(Debug)]
pub struct SynthesisCheckpointHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for SynthesisCheckpointHandle<H> {}
impl<H: HostTypes> Clone for SynthesisCheckpointHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for SynthesisCheckpointHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for SynthesisCheckpointHandle<H> {}
impl<H: HostTypes> core::hash::Hash for SynthesisCheckpointHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> SynthesisCheckpointHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait SynthesisCheckpointResolver<H: HostTypes> {
fn resolve(&self, handle: SynthesisCheckpointHandle<H>)
-> Option<SynthesisCheckpointRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct SynthesisCheckpointRecord<H: HostTypes> {
pub checkpoint_step_handle: SynthesisStepHandle<H>,
pub checkpoint_state_handle: crate::bridge::resolver::ConstraintSearchStateHandle<H>,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedSynthesisCheckpoint<'r, R: SynthesisCheckpointResolver<H>, H: HostTypes> {
handle: SynthesisCheckpointHandle<H>,
resolver: &'r R,
record: Option<SynthesisCheckpointRecord<H>>,
}
impl<'r, R: SynthesisCheckpointResolver<H>, H: HostTypes> ResolvedSynthesisCheckpoint<'r, R, H> {
#[inline]
pub fn new(handle: SynthesisCheckpointHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> SynthesisCheckpointHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&SynthesisCheckpointRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: SynthesisCheckpointResolver<H>, H: HostTypes> SynthesisCheckpoint<H>
for ResolvedSynthesisCheckpoint<'r, R, H>
{
type SynthesisStep = NullSynthesisStep<H>;
fn checkpoint_step(&self) -> &Self::SynthesisStep {
&<NullSynthesisStep<H>>::ABSENT
}
type ConstraintSearchState = crate::bridge::resolver::NullConstraintSearchState<H>;
fn checkpoint_state(&self) -> &Self::ConstraintSearchState {
&<crate::bridge::resolver::NullConstraintSearchState<H>>::ABSENT
}
}
impl<'r, R: SynthesisCheckpointResolver<H>, H: HostTypes> ResolvedSynthesisCheckpoint<'r, R, H> {
#[inline]
pub fn resolve_checkpoint_step<'r2, R2: SynthesisStepResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedSynthesisStep<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedSynthesisStep::new(record.checkpoint_step_handle, r))
}
#[inline]
pub fn resolve_checkpoint_state<
'r2,
R2: crate::bridge::resolver::ConstraintSearchStateResolver<H>,
>(
&self,
r: &'r2 R2,
) -> Option<crate::bridge::resolver::ResolvedConstraintSearchState<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::bridge::resolver::ResolvedConstraintSearchState::new(
record.checkpoint_state_handle,
r,
))
}
}
#[derive(Debug)]
pub struct InhabitanceStepHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for InhabitanceStepHandle<H> {}
impl<H: HostTypes> Clone for InhabitanceStepHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for InhabitanceStepHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for InhabitanceStepHandle<H> {}
impl<H: HostTypes> core::hash::Hash for InhabitanceStepHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> InhabitanceStepHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait InhabitanceStepResolver<H: HostTypes> {
fn resolve(&self, handle: InhabitanceStepHandle<H>) -> Option<InhabitanceStepRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct InhabitanceStepRecord<H: HostTypes> {
pub prior_state_handle: crate::bridge::resolver::ConstraintSearchStateHandle<H>,
pub successor_state_handle: crate::bridge::resolver::ConstraintSearchStateHandle<H>,
pub rule_handle: crate::kernel::predicate::DispatchRuleHandle<H>,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedInhabitanceStep<'r, R: InhabitanceStepResolver<H>, H: HostTypes> {
handle: InhabitanceStepHandle<H>,
resolver: &'r R,
record: Option<InhabitanceStepRecord<H>>,
}
impl<'r, R: InhabitanceStepResolver<H>, H: HostTypes> ResolvedInhabitanceStep<'r, R, H> {
#[inline]
pub fn new(handle: InhabitanceStepHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> InhabitanceStepHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&InhabitanceStepRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: InhabitanceStepResolver<H>, H: HostTypes> SynthesisStep<H>
for ResolvedInhabitanceStep<'r, R, H>
{
fn step_index(&self) -> u64 {
0
}
type Constraint = crate::user::type_::NullConstraint<H>;
fn added_constraint(&self) -> &Self::Constraint {
&<crate::user::type_::NullConstraint<H>>::ABSENT
}
type SynthesisSignature = crate::bridge::observable::NullSynthesisSignature<H>;
fn signature_before(&self) -> &Self::SynthesisSignature {
&<crate::bridge::observable::NullSynthesisSignature<H>>::ABSENT
}
fn signature_after(&self) -> &Self::SynthesisSignature {
&<crate::bridge::observable::NullSynthesisSignature<H>>::ABSENT
}
}
impl<'r, R: InhabitanceStepResolver<H>, H: HostTypes> InhabitanceStep<H>
for ResolvedInhabitanceStep<'r, R, H>
{
type ConstraintSearchState = crate::bridge::resolver::NullConstraintSearchState<H>;
fn prior_state(&self) -> &Self::ConstraintSearchState {
&<crate::bridge::resolver::NullConstraintSearchState<H>>::ABSENT
}
fn successor_state(&self) -> &Self::ConstraintSearchState {
&<crate::bridge::resolver::NullConstraintSearchState<H>>::ABSENT
}
type DispatchRule = crate::kernel::predicate::NullDispatchRule<H>;
fn rule(&self) -> &Self::DispatchRule {
&<crate::kernel::predicate::NullDispatchRule<H>>::ABSENT
}
}
impl<'r, R: InhabitanceStepResolver<H>, H: HostTypes> ResolvedInhabitanceStep<'r, R, H> {
#[inline]
pub fn resolve_prior_state<
'r2,
R2: crate::bridge::resolver::ConstraintSearchStateResolver<H>,
>(
&self,
r: &'r2 R2,
) -> Option<crate::bridge::resolver::ResolvedConstraintSearchState<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::bridge::resolver::ResolvedConstraintSearchState::new(
record.prior_state_handle,
r,
))
}
#[inline]
pub fn resolve_successor_state<
'r2,
R2: crate::bridge::resolver::ConstraintSearchStateResolver<H>,
>(
&self,
r: &'r2 R2,
) -> Option<crate::bridge::resolver::ResolvedConstraintSearchState<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::bridge::resolver::ResolvedConstraintSearchState::new(
record.successor_state_handle,
r,
))
}
#[inline]
pub fn resolve_rule<'r2, R2: crate::kernel::predicate::DispatchRuleResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::predicate::ResolvedDispatchRule<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::predicate::ResolvedDispatchRule::new(
record.rule_handle,
r,
))
}
}
#[derive(Debug)]
pub struct InhabitanceCheckpointHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for InhabitanceCheckpointHandle<H> {}
impl<H: HostTypes> Clone for InhabitanceCheckpointHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for InhabitanceCheckpointHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for InhabitanceCheckpointHandle<H> {}
impl<H: HostTypes> core::hash::Hash for InhabitanceCheckpointHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> InhabitanceCheckpointHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait InhabitanceCheckpointResolver<H: HostTypes> {
fn resolve(
&self,
handle: InhabitanceCheckpointHandle<H>,
) -> Option<InhabitanceCheckpointRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct InhabitanceCheckpointRecord<H: HostTypes> {
pub checkpoint_index: i64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedInhabitanceCheckpoint<'r, R: InhabitanceCheckpointResolver<H>, H: HostTypes> {
handle: InhabitanceCheckpointHandle<H>,
resolver: &'r R,
record: Option<InhabitanceCheckpointRecord<H>>,
}
impl<'r, R: InhabitanceCheckpointResolver<H>, H: HostTypes>
ResolvedInhabitanceCheckpoint<'r, R, H>
{
#[inline]
pub fn new(handle: InhabitanceCheckpointHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> InhabitanceCheckpointHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&InhabitanceCheckpointRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: InhabitanceCheckpointResolver<H>, H: HostTypes> SynthesisCheckpoint<H>
for ResolvedInhabitanceCheckpoint<'r, R, H>
{
type SynthesisStep = NullSynthesisStep<H>;
fn checkpoint_step(&self) -> &Self::SynthesisStep {
&<NullSynthesisStep<H>>::ABSENT
}
type ConstraintSearchState = crate::bridge::resolver::NullConstraintSearchState<H>;
fn checkpoint_state(&self) -> &Self::ConstraintSearchState {
&<crate::bridge::resolver::NullConstraintSearchState<H>>::ABSENT
}
}
impl<'r, R: InhabitanceCheckpointResolver<H>, H: HostTypes> InhabitanceCheckpoint<H>
for ResolvedInhabitanceCheckpoint<'r, R, H>
{
fn checkpoint_index(&self) -> i64 {
match &self.record {
Some(r) => r.checkpoint_index,
None => 0,
}
}
}
#[derive(Debug)]
pub struct DerivationDepthObservableHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for DerivationDepthObservableHandle<H> {}
impl<H: HostTypes> Clone for DerivationDepthObservableHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for DerivationDepthObservableHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for DerivationDepthObservableHandle<H> {}
impl<H: HostTypes> core::hash::Hash for DerivationDepthObservableHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> DerivationDepthObservableHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait DerivationDepthObservableResolver<H: HostTypes> {
fn resolve(
&self,
handle: DerivationDepthObservableHandle<H>,
) -> Option<DerivationDepthObservableRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct DerivationDepthObservableRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedDerivationDepthObservable<
'r,
R: DerivationDepthObservableResolver<H>,
H: HostTypes,
> {
handle: DerivationDepthObservableHandle<H>,
resolver: &'r R,
record: Option<DerivationDepthObservableRecord<H>>,
}
impl<'r, R: DerivationDepthObservableResolver<H>, H: HostTypes>
ResolvedDerivationDepthObservable<'r, R, H>
{
#[inline]
pub fn new(handle: DerivationDepthObservableHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> DerivationDepthObservableHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&DerivationDepthObservableRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: DerivationDepthObservableResolver<H>, H: HostTypes>
crate::bridge::observable::Observable<H> for ResolvedDerivationDepthObservable<'r, R, H>
{
fn value(&self) -> H::Decimal {
H::EMPTY_DECIMAL
}
fn source(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
fn target(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
fn has_unit(&self) -> MeasurementUnit {
<MeasurementUnit>::default()
}
}
impl<'r, R: DerivationDepthObservableResolver<H>, H: HostTypes> DerivationDepthObservable<H>
for ResolvedDerivationDepthObservable<'r, R, H>
{
}
#[derive(Debug)]
pub struct DerivationTraceHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for DerivationTraceHandle<H> {}
impl<H: HostTypes> Clone for DerivationTraceHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for DerivationTraceHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for DerivationTraceHandle<H> {}
impl<H: HostTypes> core::hash::Hash for DerivationTraceHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> DerivationTraceHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait DerivationTraceResolver<H: HostTypes> {
fn resolve(&self, handle: DerivationTraceHandle<H>) -> Option<DerivationTraceRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct DerivationTraceRecord<H: HostTypes> {
pub trace_event_count: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedDerivationTrace<'r, R: DerivationTraceResolver<H>, H: HostTypes> {
handle: DerivationTraceHandle<H>,
resolver: &'r R,
record: Option<DerivationTraceRecord<H>>,
}
impl<'r, R: DerivationTraceResolver<H>, H: HostTypes> ResolvedDerivationTrace<'r, R, H> {
#[inline]
pub fn new(handle: DerivationTraceHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> DerivationTraceHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&DerivationTraceRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: DerivationTraceResolver<H>, H: HostTypes> DerivationTrace<H>
for ResolvedDerivationTrace<'r, R, H>
{
fn trace_event_count(&self) -> u64 {
match &self.record {
Some(r) => r.trace_event_count,
None => 0,
}
}
}
pub mod critical_identity_rule {
pub const GROUNDED_IN: &str = "https://uor.foundation/op/criticalIdentity";
}
pub mod involution_rule {}
pub mod associativity_rule {}
pub mod commutativity_rule {}
pub mod identity_element_rule {}
pub mod normalization_rule {}