use crate::HostTypes;
pub trait ComputationResult<H: HostTypes> {}
pub trait Success<H: HostTypes>: ComputationResult<H> {
type Datum: crate::kernel::schema::Datum<H>;
fn result_datum(&self) -> &Self::Datum;
type ComputationCertificate: crate::bridge::proof::ComputationCertificate<H>;
fn result_certificate(&self) -> &Self::ComputationCertificate;
}
pub trait Failure<H: HostTypes>: ComputationResult<H> {
type FailureReason: FailureReason<H>;
fn failure_reason(&self) -> &Self::FailureReason;
type ReductionState: crate::kernel::reduction::ReductionState<H>;
fn failure_state(&self) -> &Self::ReductionState;
type ReductionStep: crate::kernel::reduction::ReductionStep<H>;
fn failure_stage(&self) -> &Self::ReductionStep;
type Recovery: Recovery<H>;
fn recovery_strategy(&self) -> &[Self::Recovery];
fn failure_depth(&self) -> u64;
}
pub trait FailureReason<H: HostTypes> {}
pub trait GuardFailure<H: HostTypes>: FailureReason<H> {}
pub trait ConstraintContradiction<H: HostTypes>: FailureReason<H> {}
pub trait SiteExhaustion<H: HostTypes>: FailureReason<H> {}
pub trait LiftObstructionFailure<H: HostTypes>: FailureReason<H> {}
pub trait PartialComputation<H: HostTypes> {
fn is_total(&self) -> bool;
}
pub trait TotalComputation<H: HostTypes>: PartialComputation<H> {}
pub trait Recovery<H: HostTypes> {
type Effect: crate::kernel::effect::Effect<H>;
fn recovery_effect(&self) -> &Self::Effect;
type ReductionStep: crate::kernel::reduction::ReductionStep<H>;
fn recovery_target(&self) -> &Self::ReductionStep;
}
pub trait FailurePropagation<H: HostTypes> {
type FailureReason: FailureReason<H>;
fn propagation_rule(&self) -> &[Self::FailureReason];
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullComputationResult<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullComputationResult<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullComputationResult<H> {
pub const ABSENT: NullComputationResult<H> = NullComputationResult {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> ComputationResult<H> for NullComputationResult<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullSuccess<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullSuccess<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullSuccess<H> {
pub const ABSENT: NullSuccess<H> = NullSuccess {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> ComputationResult<H> for NullSuccess<H> {}
impl<H: HostTypes> Success<H> for NullSuccess<H> {
type Datum = crate::kernel::schema::NullDatum<H>;
fn result_datum(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
type ComputationCertificate = crate::bridge::proof::NullComputationCertificate<H>;
fn result_certificate(&self) -> &Self::ComputationCertificate {
&<crate::bridge::proof::NullComputationCertificate<H>>::ABSENT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullFailure<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullFailure<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullFailure<H> {
pub const ABSENT: NullFailure<H> = NullFailure {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> ComputationResult<H> for NullFailure<H> {}
impl<H: HostTypes> Failure<H> for NullFailure<H> {
type FailureReason = NullFailureReason<H>;
fn failure_reason(&self) -> &Self::FailureReason {
&<NullFailureReason<H>>::ABSENT
}
type ReductionState = crate::kernel::reduction::NullReductionState<H>;
fn failure_state(&self) -> &Self::ReductionState {
&<crate::kernel::reduction::NullReductionState<H>>::ABSENT
}
type ReductionStep = crate::kernel::reduction::NullReductionStep<H>;
fn failure_stage(&self) -> &Self::ReductionStep {
&<crate::kernel::reduction::NullReductionStep<H>>::ABSENT
}
type Recovery = NullRecovery<H>;
fn recovery_strategy(&self) -> &[Self::Recovery] {
&[]
}
fn failure_depth(&self) -> u64 {
0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullFailureReason<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullFailureReason<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullFailureReason<H> {
pub const ABSENT: NullFailureReason<H> = NullFailureReason {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> FailureReason<H> for NullFailureReason<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullGuardFailure<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullGuardFailure<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullGuardFailure<H> {
pub const ABSENT: NullGuardFailure<H> = NullGuardFailure {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> FailureReason<H> for NullGuardFailure<H> {}
impl<H: HostTypes> GuardFailure<H> for NullGuardFailure<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullConstraintContradiction<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullConstraintContradiction<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullConstraintContradiction<H> {
pub const ABSENT: NullConstraintContradiction<H> = NullConstraintContradiction {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> FailureReason<H> for NullConstraintContradiction<H> {}
impl<H: HostTypes> ConstraintContradiction<H> for NullConstraintContradiction<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullSiteExhaustion<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullSiteExhaustion<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullSiteExhaustion<H> {
pub const ABSENT: NullSiteExhaustion<H> = NullSiteExhaustion {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> FailureReason<H> for NullSiteExhaustion<H> {}
impl<H: HostTypes> SiteExhaustion<H> for NullSiteExhaustion<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullLiftObstructionFailure<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullLiftObstructionFailure<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullLiftObstructionFailure<H> {
pub const ABSENT: NullLiftObstructionFailure<H> = NullLiftObstructionFailure {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> FailureReason<H> for NullLiftObstructionFailure<H> {}
impl<H: HostTypes> LiftObstructionFailure<H> for NullLiftObstructionFailure<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullPartialComputation<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullPartialComputation<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullPartialComputation<H> {
pub const ABSENT: NullPartialComputation<H> = NullPartialComputation {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> PartialComputation<H> for NullPartialComputation<H> {
fn is_total(&self) -> bool {
false
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullTotalComputation<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullTotalComputation<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullTotalComputation<H> {
pub const ABSENT: NullTotalComputation<H> = NullTotalComputation {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> PartialComputation<H> for NullTotalComputation<H> {
fn is_total(&self) -> bool {
false
}
}
impl<H: HostTypes> TotalComputation<H> for NullTotalComputation<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullRecovery<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullRecovery<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullRecovery<H> {
pub const ABSENT: NullRecovery<H> = NullRecovery {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> Recovery<H> for NullRecovery<H> {
type Effect = crate::kernel::effect::NullEffect<H>;
fn recovery_effect(&self) -> &Self::Effect {
&<crate::kernel::effect::NullEffect<H>>::ABSENT
}
type ReductionStep = crate::kernel::reduction::NullReductionStep<H>;
fn recovery_target(&self) -> &Self::ReductionStep {
&<crate::kernel::reduction::NullReductionStep<H>>::ABSENT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullFailurePropagation<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullFailurePropagation<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullFailurePropagation<H> {
pub const ABSENT: NullFailurePropagation<H> = NullFailurePropagation {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> FailurePropagation<H> for NullFailurePropagation<H> {
type FailureReason = NullFailureReason<H>;
fn propagation_rule(&self) -> &[Self::FailureReason] {
&[]
}
}
#[derive(Debug)]
pub struct ComputationResultHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for ComputationResultHandle<H> {}
impl<H: HostTypes> Clone for ComputationResultHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for ComputationResultHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for ComputationResultHandle<H> {}
impl<H: HostTypes> core::hash::Hash for ComputationResultHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> ComputationResultHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait ComputationResultResolver<H: HostTypes> {
fn resolve(&self, handle: ComputationResultHandle<H>) -> Option<ComputationResultRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct ComputationResultRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedComputationResult<'r, R: ComputationResultResolver<H>, H: HostTypes> {
handle: ComputationResultHandle<H>,
resolver: &'r R,
record: Option<ComputationResultRecord<H>>,
}
impl<'r, R: ComputationResultResolver<H>, H: HostTypes> ResolvedComputationResult<'r, R, H> {
#[inline]
pub fn new(handle: ComputationResultHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> ComputationResultHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&ComputationResultRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: ComputationResultResolver<H>, H: HostTypes> ComputationResult<H>
for ResolvedComputationResult<'r, R, H>
{
}
#[derive(Debug)]
pub struct SuccessHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for SuccessHandle<H> {}
impl<H: HostTypes> Clone for SuccessHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for SuccessHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for SuccessHandle<H> {}
impl<H: HostTypes> core::hash::Hash for SuccessHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> SuccessHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait SuccessResolver<H: HostTypes> {
fn resolve(&self, handle: SuccessHandle<H>) -> Option<SuccessRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct SuccessRecord<H: HostTypes> {
pub result_datum_handle: crate::kernel::schema::DatumHandle<H>,
pub result_certificate_handle: crate::bridge::proof::ComputationCertificateHandle<H>,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedSuccess<'r, R: SuccessResolver<H>, H: HostTypes> {
handle: SuccessHandle<H>,
resolver: &'r R,
record: Option<SuccessRecord<H>>,
}
impl<'r, R: SuccessResolver<H>, H: HostTypes> ResolvedSuccess<'r, R, H> {
#[inline]
pub fn new(handle: SuccessHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> SuccessHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&SuccessRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: SuccessResolver<H>, H: HostTypes> ComputationResult<H> for ResolvedSuccess<'r, R, H> {}
impl<'r, R: SuccessResolver<H>, H: HostTypes> Success<H> for ResolvedSuccess<'r, R, H> {
type Datum = crate::kernel::schema::NullDatum<H>;
fn result_datum(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
type ComputationCertificate = crate::bridge::proof::NullComputationCertificate<H>;
fn result_certificate(&self) -> &Self::ComputationCertificate {
&<crate::bridge::proof::NullComputationCertificate<H>>::ABSENT
}
}
impl<'r, R: SuccessResolver<H>, H: HostTypes> ResolvedSuccess<'r, R, H> {
#[inline]
pub fn resolve_result_datum<'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_datum_handle,
r,
))
}
#[inline]
pub fn resolve_result_certificate<
'r2,
R2: crate::bridge::proof::ComputationCertificateResolver<H>,
>(
&self,
r: &'r2 R2,
) -> Option<crate::bridge::proof::ResolvedComputationCertificate<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::bridge::proof::ResolvedComputationCertificate::new(
record.result_certificate_handle,
r,
))
}
}
#[derive(Debug)]
pub struct FailureHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for FailureHandle<H> {}
impl<H: HostTypes> Clone for FailureHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for FailureHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for FailureHandle<H> {}
impl<H: HostTypes> core::hash::Hash for FailureHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> FailureHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait FailureResolver<H: HostTypes> {
fn resolve(&self, handle: FailureHandle<H>) -> Option<FailureRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct FailureRecord<H: HostTypes> {
pub failure_reason_handle: FailureReasonHandle<H>,
pub failure_state_handle: crate::kernel::reduction::ReductionStateHandle<H>,
pub failure_stage_handle: crate::kernel::reduction::ReductionStepHandle<H>,
pub failure_depth: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedFailure<'r, R: FailureResolver<H>, H: HostTypes> {
handle: FailureHandle<H>,
resolver: &'r R,
record: Option<FailureRecord<H>>,
}
impl<'r, R: FailureResolver<H>, H: HostTypes> ResolvedFailure<'r, R, H> {
#[inline]
pub fn new(handle: FailureHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> FailureHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&FailureRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: FailureResolver<H>, H: HostTypes> ComputationResult<H> for ResolvedFailure<'r, R, H> {}
impl<'r, R: FailureResolver<H>, H: HostTypes> Failure<H> for ResolvedFailure<'r, R, H> {
type FailureReason = NullFailureReason<H>;
fn failure_reason(&self) -> &Self::FailureReason {
&<NullFailureReason<H>>::ABSENT
}
type ReductionState = crate::kernel::reduction::NullReductionState<H>;
fn failure_state(&self) -> &Self::ReductionState {
&<crate::kernel::reduction::NullReductionState<H>>::ABSENT
}
type ReductionStep = crate::kernel::reduction::NullReductionStep<H>;
fn failure_stage(&self) -> &Self::ReductionStep {
&<crate::kernel::reduction::NullReductionStep<H>>::ABSENT
}
type Recovery = NullRecovery<H>;
fn recovery_strategy(&self) -> &[Self::Recovery] {
&[]
}
fn failure_depth(&self) -> u64 {
match &self.record {
Some(r) => r.failure_depth,
None => 0,
}
}
}
impl<'r, R: FailureResolver<H>, H: HostTypes> ResolvedFailure<'r, R, H> {
#[inline]
pub fn resolve_failure_reason<'r2, R2: FailureReasonResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedFailureReason<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedFailureReason::new(record.failure_reason_handle, r))
}
#[inline]
pub fn resolve_failure_state<'r2, R2: crate::kernel::reduction::ReductionStateResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::reduction::ResolvedReductionState<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::reduction::ResolvedReductionState::new(
record.failure_state_handle,
r,
))
}
#[inline]
pub fn resolve_failure_stage<'r2, R2: crate::kernel::reduction::ReductionStepResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::reduction::ResolvedReductionStep<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::reduction::ResolvedReductionStep::new(
record.failure_stage_handle,
r,
))
}
}
#[derive(Debug)]
pub struct FailureReasonHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for FailureReasonHandle<H> {}
impl<H: HostTypes> Clone for FailureReasonHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for FailureReasonHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for FailureReasonHandle<H> {}
impl<H: HostTypes> core::hash::Hash for FailureReasonHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> FailureReasonHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait FailureReasonResolver<H: HostTypes> {
fn resolve(&self, handle: FailureReasonHandle<H>) -> Option<FailureReasonRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct FailureReasonRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedFailureReason<'r, R: FailureReasonResolver<H>, H: HostTypes> {
handle: FailureReasonHandle<H>,
resolver: &'r R,
record: Option<FailureReasonRecord<H>>,
}
impl<'r, R: FailureReasonResolver<H>, H: HostTypes> ResolvedFailureReason<'r, R, H> {
#[inline]
pub fn new(handle: FailureReasonHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> FailureReasonHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&FailureReasonRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: FailureReasonResolver<H>, H: HostTypes> FailureReason<H>
for ResolvedFailureReason<'r, R, H>
{
}
#[derive(Debug)]
pub struct GuardFailureHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for GuardFailureHandle<H> {}
impl<H: HostTypes> Clone for GuardFailureHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for GuardFailureHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for GuardFailureHandle<H> {}
impl<H: HostTypes> core::hash::Hash for GuardFailureHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> GuardFailureHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait GuardFailureResolver<H: HostTypes> {
fn resolve(&self, handle: GuardFailureHandle<H>) -> Option<GuardFailureRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct GuardFailureRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedGuardFailure<'r, R: GuardFailureResolver<H>, H: HostTypes> {
handle: GuardFailureHandle<H>,
resolver: &'r R,
record: Option<GuardFailureRecord<H>>,
}
impl<'r, R: GuardFailureResolver<H>, H: HostTypes> ResolvedGuardFailure<'r, R, H> {
#[inline]
pub fn new(handle: GuardFailureHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> GuardFailureHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&GuardFailureRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: GuardFailureResolver<H>, H: HostTypes> FailureReason<H>
for ResolvedGuardFailure<'r, R, H>
{
}
impl<'r, R: GuardFailureResolver<H>, H: HostTypes> GuardFailure<H>
for ResolvedGuardFailure<'r, R, H>
{
}
#[derive(Debug)]
pub struct ConstraintContradictionHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for ConstraintContradictionHandle<H> {}
impl<H: HostTypes> Clone for ConstraintContradictionHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for ConstraintContradictionHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for ConstraintContradictionHandle<H> {}
impl<H: HostTypes> core::hash::Hash for ConstraintContradictionHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> ConstraintContradictionHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait ConstraintContradictionResolver<H: HostTypes> {
fn resolve(
&self,
handle: ConstraintContradictionHandle<H>,
) -> Option<ConstraintContradictionRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct ConstraintContradictionRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedConstraintContradiction<'r, R: ConstraintContradictionResolver<H>, H: HostTypes>
{
handle: ConstraintContradictionHandle<H>,
resolver: &'r R,
record: Option<ConstraintContradictionRecord<H>>,
}
impl<'r, R: ConstraintContradictionResolver<H>, H: HostTypes>
ResolvedConstraintContradiction<'r, R, H>
{
#[inline]
pub fn new(handle: ConstraintContradictionHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> ConstraintContradictionHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&ConstraintContradictionRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: ConstraintContradictionResolver<H>, H: HostTypes> FailureReason<H>
for ResolvedConstraintContradiction<'r, R, H>
{
}
impl<'r, R: ConstraintContradictionResolver<H>, H: HostTypes> ConstraintContradiction<H>
for ResolvedConstraintContradiction<'r, R, H>
{
}
#[derive(Debug)]
pub struct SiteExhaustionHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for SiteExhaustionHandle<H> {}
impl<H: HostTypes> Clone for SiteExhaustionHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for SiteExhaustionHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for SiteExhaustionHandle<H> {}
impl<H: HostTypes> core::hash::Hash for SiteExhaustionHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> SiteExhaustionHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait SiteExhaustionResolver<H: HostTypes> {
fn resolve(&self, handle: SiteExhaustionHandle<H>) -> Option<SiteExhaustionRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct SiteExhaustionRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedSiteExhaustion<'r, R: SiteExhaustionResolver<H>, H: HostTypes> {
handle: SiteExhaustionHandle<H>,
resolver: &'r R,
record: Option<SiteExhaustionRecord<H>>,
}
impl<'r, R: SiteExhaustionResolver<H>, H: HostTypes> ResolvedSiteExhaustion<'r, R, H> {
#[inline]
pub fn new(handle: SiteExhaustionHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> SiteExhaustionHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&SiteExhaustionRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: SiteExhaustionResolver<H>, H: HostTypes> FailureReason<H>
for ResolvedSiteExhaustion<'r, R, H>
{
}
impl<'r, R: SiteExhaustionResolver<H>, H: HostTypes> SiteExhaustion<H>
for ResolvedSiteExhaustion<'r, R, H>
{
}
#[derive(Debug)]
pub struct LiftObstructionFailureHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for LiftObstructionFailureHandle<H> {}
impl<H: HostTypes> Clone for LiftObstructionFailureHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for LiftObstructionFailureHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for LiftObstructionFailureHandle<H> {}
impl<H: HostTypes> core::hash::Hash for LiftObstructionFailureHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> LiftObstructionFailureHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait LiftObstructionFailureResolver<H: HostTypes> {
fn resolve(
&self,
handle: LiftObstructionFailureHandle<H>,
) -> Option<LiftObstructionFailureRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct LiftObstructionFailureRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedLiftObstructionFailure<'r, R: LiftObstructionFailureResolver<H>, H: HostTypes> {
handle: LiftObstructionFailureHandle<H>,
resolver: &'r R,
record: Option<LiftObstructionFailureRecord<H>>,
}
impl<'r, R: LiftObstructionFailureResolver<H>, H: HostTypes>
ResolvedLiftObstructionFailure<'r, R, H>
{
#[inline]
pub fn new(handle: LiftObstructionFailureHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> LiftObstructionFailureHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&LiftObstructionFailureRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: LiftObstructionFailureResolver<H>, H: HostTypes> FailureReason<H>
for ResolvedLiftObstructionFailure<'r, R, H>
{
}
impl<'r, R: LiftObstructionFailureResolver<H>, H: HostTypes> LiftObstructionFailure<H>
for ResolvedLiftObstructionFailure<'r, R, H>
{
}
#[derive(Debug)]
pub struct PartialComputationHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for PartialComputationHandle<H> {}
impl<H: HostTypes> Clone for PartialComputationHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for PartialComputationHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for PartialComputationHandle<H> {}
impl<H: HostTypes> core::hash::Hash for PartialComputationHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> PartialComputationHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait PartialComputationResolver<H: HostTypes> {
fn resolve(&self, handle: PartialComputationHandle<H>) -> Option<PartialComputationRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct PartialComputationRecord<H: HostTypes> {
pub is_total: bool,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedPartialComputation<'r, R: PartialComputationResolver<H>, H: HostTypes> {
handle: PartialComputationHandle<H>,
resolver: &'r R,
record: Option<PartialComputationRecord<H>>,
}
impl<'r, R: PartialComputationResolver<H>, H: HostTypes> ResolvedPartialComputation<'r, R, H> {
#[inline]
pub fn new(handle: PartialComputationHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> PartialComputationHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&PartialComputationRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: PartialComputationResolver<H>, H: HostTypes> PartialComputation<H>
for ResolvedPartialComputation<'r, R, H>
{
fn is_total(&self) -> bool {
match &self.record {
Some(r) => r.is_total,
None => false,
}
}
}
#[derive(Debug)]
pub struct TotalComputationHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for TotalComputationHandle<H> {}
impl<H: HostTypes> Clone for TotalComputationHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for TotalComputationHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for TotalComputationHandle<H> {}
impl<H: HostTypes> core::hash::Hash for TotalComputationHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> TotalComputationHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait TotalComputationResolver<H: HostTypes> {
fn resolve(&self, handle: TotalComputationHandle<H>) -> Option<TotalComputationRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct TotalComputationRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedTotalComputation<'r, R: TotalComputationResolver<H>, H: HostTypes> {
handle: TotalComputationHandle<H>,
resolver: &'r R,
record: Option<TotalComputationRecord<H>>,
}
impl<'r, R: TotalComputationResolver<H>, H: HostTypes> ResolvedTotalComputation<'r, R, H> {
#[inline]
pub fn new(handle: TotalComputationHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> TotalComputationHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&TotalComputationRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: TotalComputationResolver<H>, H: HostTypes> PartialComputation<H>
for ResolvedTotalComputation<'r, R, H>
{
fn is_total(&self) -> bool {
false
}
}
impl<'r, R: TotalComputationResolver<H>, H: HostTypes> TotalComputation<H>
for ResolvedTotalComputation<'r, R, H>
{
}
#[derive(Debug)]
pub struct RecoveryHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for RecoveryHandle<H> {}
impl<H: HostTypes> Clone for RecoveryHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for RecoveryHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for RecoveryHandle<H> {}
impl<H: HostTypes> core::hash::Hash for RecoveryHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> RecoveryHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait RecoveryResolver<H: HostTypes> {
fn resolve(&self, handle: RecoveryHandle<H>) -> Option<RecoveryRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct RecoveryRecord<H: HostTypes> {
pub recovery_effect_handle: crate::kernel::effect::EffectHandle<H>,
pub recovery_target_handle: crate::kernel::reduction::ReductionStepHandle<H>,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedRecovery<'r, R: RecoveryResolver<H>, H: HostTypes> {
handle: RecoveryHandle<H>,
resolver: &'r R,
record: Option<RecoveryRecord<H>>,
}
impl<'r, R: RecoveryResolver<H>, H: HostTypes> ResolvedRecovery<'r, R, H> {
#[inline]
pub fn new(handle: RecoveryHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> RecoveryHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&RecoveryRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: RecoveryResolver<H>, H: HostTypes> Recovery<H> for ResolvedRecovery<'r, R, H> {
type Effect = crate::kernel::effect::NullEffect<H>;
fn recovery_effect(&self) -> &Self::Effect {
&<crate::kernel::effect::NullEffect<H>>::ABSENT
}
type ReductionStep = crate::kernel::reduction::NullReductionStep<H>;
fn recovery_target(&self) -> &Self::ReductionStep {
&<crate::kernel::reduction::NullReductionStep<H>>::ABSENT
}
}
impl<'r, R: RecoveryResolver<H>, H: HostTypes> ResolvedRecovery<'r, R, H> {
#[inline]
pub fn resolve_recovery_effect<'r2, R2: crate::kernel::effect::EffectResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::effect::ResolvedEffect<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::effect::ResolvedEffect::new(
record.recovery_effect_handle,
r,
))
}
#[inline]
pub fn resolve_recovery_target<'r2, R2: crate::kernel::reduction::ReductionStepResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::reduction::ResolvedReductionStep<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::reduction::ResolvedReductionStep::new(
record.recovery_target_handle,
r,
))
}
}
#[derive(Debug)]
pub struct FailurePropagationHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for FailurePropagationHandle<H> {}
impl<H: HostTypes> Clone for FailurePropagationHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for FailurePropagationHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for FailurePropagationHandle<H> {}
impl<H: HostTypes> core::hash::Hash for FailurePropagationHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> FailurePropagationHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait FailurePropagationResolver<H: HostTypes> {
fn resolve(&self, handle: FailurePropagationHandle<H>) -> Option<FailurePropagationRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct FailurePropagationRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedFailurePropagation<'r, R: FailurePropagationResolver<H>, H: HostTypes> {
handle: FailurePropagationHandle<H>,
resolver: &'r R,
record: Option<FailurePropagationRecord<H>>,
}
impl<'r, R: FailurePropagationResolver<H>, H: HostTypes> ResolvedFailurePropagation<'r, R, H> {
#[inline]
pub fn new(handle: FailurePropagationHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> FailurePropagationHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&FailurePropagationRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: FailurePropagationResolver<H>, H: HostTypes> FailurePropagation<H>
for ResolvedFailurePropagation<'r, R, H>
{
type FailureReason = NullFailureReason<H>;
fn propagation_rule(&self) -> &[Self::FailureReason] {
&[]
}
}