use crate::HostTypes;
pub trait LinearSite<H: HostTypes>: crate::bridge::partition::SiteIndex<H> {}
pub trait LinearEffect<H: HostTypes>: crate::kernel::effect::PinningEffect<H> {
type LinearSite: LinearSite<H>;
fn linear_target(&self) -> &Self::LinearSite;
}
pub trait LinearTrace<H: HostTypes>: crate::bridge::trace::ComputationTrace<H> {}
pub trait LinearBudget<H: HostTypes> {
type LinearSite: LinearSite<H>;
fn budget_sites(&self) -> &[Self::LinearSite];
type Context: crate::user::state::Context<H>;
fn budget_context(&self) -> &Self::Context;
fn remaining_count(&self) -> u64;
fn stack_budget_bytes(&self) -> u64;
}
pub trait LeaseAllocation<H: HostTypes> {
type LinearSite: LinearSite<H>;
fn lease_target(&self) -> &[Self::LinearSite];
type ContextLease: crate::user::state::ContextLease<H>;
fn lease_source(&self) -> &Self::ContextLease;
fn lease_cardinality(&self) -> u64;
}
pub trait AffineSite<H: HostTypes>: crate::bridge::partition::SiteIndex<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullLinearSite<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullLinearSite<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullLinearSite<H> {
pub const ABSENT: NullLinearSite<H> = NullLinearSite {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> crate::bridge::partition::SiteIndex<H> for NullLinearSite<H> {
fn site_position(&self) -> u64 {
0
}
fn site_state(&self) -> u64 {
0
}
type SiteIndexTarget = crate::bridge::partition::NullSiteIndex<H>;
fn ancilla_site(&self) -> &Self::SiteIndexTarget {
&<crate::bridge::partition::NullSiteIndex<H>>::ABSENT
}
}
impl<H: HostTypes> LinearSite<H> for NullLinearSite<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullLinearEffect<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullLinearEffect<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullLinearEffect<H> {
pub const ABSENT: NullLinearEffect<H> = NullLinearEffect {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> crate::kernel::effect::Effect<H> for NullLinearEffect<H> {
type EffectTarget = crate::kernel::effect::NullEffectTarget<H>;
fn effect_target(&self) -> &Self::EffectTarget {
&<crate::kernel::effect::NullEffectTarget<H>>::ABSENT
}
type Context = crate::user::state::NullContext<H>;
fn pre_context(&self) -> &Self::Context {
&<crate::user::state::NullContext<H>>::ABSENT
}
fn post_context(&self) -> &Self::Context {
&<crate::user::state::NullContext<H>>::ABSENT
}
fn free_rank_delta(&self) -> i64 {
0
}
fn composite_index(&self) -> u64 {
0
}
fn is_commutative_with(&self) -> bool {
false
}
}
impl<H: HostTypes> crate::kernel::effect::ReversibleEffect<H> for NullLinearEffect<H> {}
impl<H: HostTypes> crate::kernel::effect::PinningEffect<H> for NullLinearEffect<H> {}
impl<H: HostTypes> LinearEffect<H> for NullLinearEffect<H> {
type LinearSite = NullLinearSite<H>;
fn linear_target(&self) -> &Self::LinearSite {
&<NullLinearSite<H>>::ABSENT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullLinearTrace<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullLinearTrace<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullLinearTrace<H> {
pub const ABSENT: NullLinearTrace<H> = NullLinearTrace {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> crate::bridge::trace::ComputationTrace<H> for NullLinearTrace<H> {
type Datum = crate::kernel::schema::NullDatum<H>;
fn input(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
fn output(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
type ComputationStep = crate::bridge::trace::NullComputationStep<H>;
fn step(&self) -> &[Self::ComputationStep] {
&[]
}
type DihedralElement = crate::bridge::observable::NullDihedralElement<H>;
fn monodromy(&self) -> &Self::DihedralElement {
&<crate::bridge::observable::NullDihedralElement<H>>::ABSENT
}
type Certificate = crate::bridge::cert::NullCertificate<H>;
fn certified_by(&self) -> &Self::Certificate {
&<crate::bridge::cert::NullCertificate<H>>::ABSENT
}
type ResidualEntropy = crate::bridge::observable::NullResidualEntropy<H>;
fn residual_entropy(&self) -> &Self::ResidualEntropy {
&<crate::bridge::observable::NullResidualEntropy<H>>::ABSENT
}
fn is_geodesic(&self) -> bool {
false
}
type GeodesicViolation = crate::bridge::trace::NullGeodesicViolation<H>;
fn geodesic_violation(&self) -> &[Self::GeodesicViolation] {
&[]
}
fn cumulative_entropy_cost(&self) -> H::Decimal {
H::EMPTY_DECIMAL
}
fn adiabatically_ordered(&self) -> bool {
false
}
type MeasurementEvent = crate::bridge::trace::NullMeasurementEvent<H>;
fn measurement_event(&self) -> &[Self::MeasurementEvent] {
&[]
}
fn is_ar1_ordered(&self) -> bool {
false
}
fn is_dc10_selected(&self) -> bool {
false
}
}
impl<H: HostTypes> LinearTrace<H> for NullLinearTrace<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullLinearBudget<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullLinearBudget<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullLinearBudget<H> {
pub const ABSENT: NullLinearBudget<H> = NullLinearBudget {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> LinearBudget<H> for NullLinearBudget<H> {
type LinearSite = NullLinearSite<H>;
fn budget_sites(&self) -> &[Self::LinearSite] {
&[]
}
type Context = crate::user::state::NullContext<H>;
fn budget_context(&self) -> &Self::Context {
&<crate::user::state::NullContext<H>>::ABSENT
}
fn remaining_count(&self) -> u64 {
0
}
fn stack_budget_bytes(&self) -> u64 {
0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullLeaseAllocation<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullLeaseAllocation<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullLeaseAllocation<H> {
pub const ABSENT: NullLeaseAllocation<H> = NullLeaseAllocation {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> LeaseAllocation<H> for NullLeaseAllocation<H> {
type LinearSite = NullLinearSite<H>;
fn lease_target(&self) -> &[Self::LinearSite] {
&[]
}
type ContextLease = crate::user::state::NullContextLease<H>;
fn lease_source(&self) -> &Self::ContextLease {
&<crate::user::state::NullContextLease<H>>::ABSENT
}
fn lease_cardinality(&self) -> u64 {
0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullAffineSite<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullAffineSite<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullAffineSite<H> {
pub const ABSENT: NullAffineSite<H> = NullAffineSite {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> crate::bridge::partition::SiteIndex<H> for NullAffineSite<H> {
fn site_position(&self) -> u64 {
0
}
fn site_state(&self) -> u64 {
0
}
type SiteIndexTarget = crate::bridge::partition::NullSiteIndex<H>;
fn ancilla_site(&self) -> &Self::SiteIndexTarget {
&<crate::bridge::partition::NullSiteIndex<H>>::ABSENT
}
}
impl<H: HostTypes> AffineSite<H> for NullAffineSite<H> {}
#[derive(Debug)]
pub struct LinearSiteHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for LinearSiteHandle<H> {}
impl<H: HostTypes> Clone for LinearSiteHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for LinearSiteHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for LinearSiteHandle<H> {}
impl<H: HostTypes> core::hash::Hash for LinearSiteHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> LinearSiteHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait LinearSiteResolver<H: HostTypes> {
fn resolve(&self, handle: LinearSiteHandle<H>) -> Option<LinearSiteRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct LinearSiteRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedLinearSite<'r, R: LinearSiteResolver<H>, H: HostTypes> {
handle: LinearSiteHandle<H>,
resolver: &'r R,
record: Option<LinearSiteRecord<H>>,
}
impl<'r, R: LinearSiteResolver<H>, H: HostTypes> ResolvedLinearSite<'r, R, H> {
#[inline]
pub fn new(handle: LinearSiteHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> LinearSiteHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&LinearSiteRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: LinearSiteResolver<H>, H: HostTypes> crate::bridge::partition::SiteIndex<H>
for ResolvedLinearSite<'r, R, H>
{
fn site_position(&self) -> u64 {
0
}
fn site_state(&self) -> u64 {
0
}
type SiteIndexTarget = crate::bridge::partition::NullSiteIndex<H>;
fn ancilla_site(&self) -> &Self::SiteIndexTarget {
&<crate::bridge::partition::NullSiteIndex<H>>::ABSENT
}
}
impl<'r, R: LinearSiteResolver<H>, H: HostTypes> LinearSite<H> for ResolvedLinearSite<'r, R, H> {}
#[derive(Debug)]
pub struct LinearEffectHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for LinearEffectHandle<H> {}
impl<H: HostTypes> Clone for LinearEffectHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for LinearEffectHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for LinearEffectHandle<H> {}
impl<H: HostTypes> core::hash::Hash for LinearEffectHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> LinearEffectHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait LinearEffectResolver<H: HostTypes> {
fn resolve(&self, handle: LinearEffectHandle<H>) -> Option<LinearEffectRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct LinearEffectRecord<H: HostTypes> {
pub linear_target_handle: LinearSiteHandle<H>,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedLinearEffect<'r, R: LinearEffectResolver<H>, H: HostTypes> {
handle: LinearEffectHandle<H>,
resolver: &'r R,
record: Option<LinearEffectRecord<H>>,
}
impl<'r, R: LinearEffectResolver<H>, H: HostTypes> ResolvedLinearEffect<'r, R, H> {
#[inline]
pub fn new(handle: LinearEffectHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> LinearEffectHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&LinearEffectRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: LinearEffectResolver<H>, H: HostTypes> crate::kernel::effect::Effect<H>
for ResolvedLinearEffect<'r, R, H>
{
type EffectTarget = crate::kernel::effect::NullEffectTarget<H>;
fn effect_target(&self) -> &Self::EffectTarget {
&<crate::kernel::effect::NullEffectTarget<H>>::ABSENT
}
type Context = crate::user::state::NullContext<H>;
fn pre_context(&self) -> &Self::Context {
&<crate::user::state::NullContext<H>>::ABSENT
}
fn post_context(&self) -> &Self::Context {
&<crate::user::state::NullContext<H>>::ABSENT
}
fn free_rank_delta(&self) -> i64 {
0
}
fn composite_index(&self) -> u64 {
0
}
fn is_commutative_with(&self) -> bool {
false
}
}
impl<'r, R: LinearEffectResolver<H>, H: HostTypes> crate::kernel::effect::ReversibleEffect<H>
for ResolvedLinearEffect<'r, R, H>
{
}
impl<'r, R: LinearEffectResolver<H>, H: HostTypes> crate::kernel::effect::PinningEffect<H>
for ResolvedLinearEffect<'r, R, H>
{
}
impl<'r, R: LinearEffectResolver<H>, H: HostTypes> LinearEffect<H>
for ResolvedLinearEffect<'r, R, H>
{
type LinearSite = NullLinearSite<H>;
fn linear_target(&self) -> &Self::LinearSite {
&<NullLinearSite<H>>::ABSENT
}
}
impl<'r, R: LinearEffectResolver<H>, H: HostTypes> ResolvedLinearEffect<'r, R, H> {
#[inline]
pub fn resolve_linear_target<'r2, R2: LinearSiteResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedLinearSite<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedLinearSite::new(record.linear_target_handle, r))
}
}
#[derive(Debug)]
pub struct LinearTraceHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for LinearTraceHandle<H> {}
impl<H: HostTypes> Clone for LinearTraceHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for LinearTraceHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for LinearTraceHandle<H> {}
impl<H: HostTypes> core::hash::Hash for LinearTraceHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> LinearTraceHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait LinearTraceResolver<H: HostTypes> {
fn resolve(&self, handle: LinearTraceHandle<H>) -> Option<LinearTraceRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct LinearTraceRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedLinearTrace<'r, R: LinearTraceResolver<H>, H: HostTypes> {
handle: LinearTraceHandle<H>,
resolver: &'r R,
record: Option<LinearTraceRecord<H>>,
}
impl<'r, R: LinearTraceResolver<H>, H: HostTypes> ResolvedLinearTrace<'r, R, H> {
#[inline]
pub fn new(handle: LinearTraceHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> LinearTraceHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&LinearTraceRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: LinearTraceResolver<H>, H: HostTypes> crate::bridge::trace::ComputationTrace<H>
for ResolvedLinearTrace<'r, R, H>
{
type Datum = crate::kernel::schema::NullDatum<H>;
fn input(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
fn output(&self) -> &Self::Datum {
&<crate::kernel::schema::NullDatum<H>>::ABSENT
}
type ComputationStep = crate::bridge::trace::NullComputationStep<H>;
fn step(&self) -> &[Self::ComputationStep] {
&[]
}
type DihedralElement = crate::bridge::observable::NullDihedralElement<H>;
fn monodromy(&self) -> &Self::DihedralElement {
&<crate::bridge::observable::NullDihedralElement<H>>::ABSENT
}
type Certificate = crate::bridge::cert::NullCertificate<H>;
fn certified_by(&self) -> &Self::Certificate {
&<crate::bridge::cert::NullCertificate<H>>::ABSENT
}
type ResidualEntropy = crate::bridge::observable::NullResidualEntropy<H>;
fn residual_entropy(&self) -> &Self::ResidualEntropy {
&<crate::bridge::observable::NullResidualEntropy<H>>::ABSENT
}
fn is_geodesic(&self) -> bool {
false
}
type GeodesicViolation = crate::bridge::trace::NullGeodesicViolation<H>;
fn geodesic_violation(&self) -> &[Self::GeodesicViolation] {
&[]
}
fn cumulative_entropy_cost(&self) -> H::Decimal {
H::EMPTY_DECIMAL
}
fn adiabatically_ordered(&self) -> bool {
false
}
type MeasurementEvent = crate::bridge::trace::NullMeasurementEvent<H>;
fn measurement_event(&self) -> &[Self::MeasurementEvent] {
&[]
}
fn is_ar1_ordered(&self) -> bool {
false
}
fn is_dc10_selected(&self) -> bool {
false
}
}
impl<'r, R: LinearTraceResolver<H>, H: HostTypes> LinearTrace<H> for ResolvedLinearTrace<'r, R, H> {}
#[derive(Debug)]
pub struct LinearBudgetHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for LinearBudgetHandle<H> {}
impl<H: HostTypes> Clone for LinearBudgetHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for LinearBudgetHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for LinearBudgetHandle<H> {}
impl<H: HostTypes> core::hash::Hash for LinearBudgetHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> LinearBudgetHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait LinearBudgetResolver<H: HostTypes> {
fn resolve(&self, handle: LinearBudgetHandle<H>) -> Option<LinearBudgetRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct LinearBudgetRecord<H: HostTypes> {
pub budget_context_handle: crate::user::state::ContextHandle<H>,
pub remaining_count: u64,
pub stack_budget_bytes: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedLinearBudget<'r, R: LinearBudgetResolver<H>, H: HostTypes> {
handle: LinearBudgetHandle<H>,
resolver: &'r R,
record: Option<LinearBudgetRecord<H>>,
}
impl<'r, R: LinearBudgetResolver<H>, H: HostTypes> ResolvedLinearBudget<'r, R, H> {
#[inline]
pub fn new(handle: LinearBudgetHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> LinearBudgetHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&LinearBudgetRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: LinearBudgetResolver<H>, H: HostTypes> LinearBudget<H>
for ResolvedLinearBudget<'r, R, H>
{
type LinearSite = NullLinearSite<H>;
fn budget_sites(&self) -> &[Self::LinearSite] {
&[]
}
type Context = crate::user::state::NullContext<H>;
fn budget_context(&self) -> &Self::Context {
&<crate::user::state::NullContext<H>>::ABSENT
}
fn remaining_count(&self) -> u64 {
match &self.record {
Some(r) => r.remaining_count,
None => 0,
}
}
fn stack_budget_bytes(&self) -> u64 {
match &self.record {
Some(r) => r.stack_budget_bytes,
None => 0,
}
}
}
impl<'r, R: LinearBudgetResolver<H>, H: HostTypes> ResolvedLinearBudget<'r, R, H> {
#[inline]
pub fn resolve_budget_context<'r2, R2: crate::user::state::ContextResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::user::state::ResolvedContext<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::user::state::ResolvedContext::new(
record.budget_context_handle,
r,
))
}
}
#[derive(Debug)]
pub struct LeaseAllocationHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for LeaseAllocationHandle<H> {}
impl<H: HostTypes> Clone for LeaseAllocationHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for LeaseAllocationHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for LeaseAllocationHandle<H> {}
impl<H: HostTypes> core::hash::Hash for LeaseAllocationHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> LeaseAllocationHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait LeaseAllocationResolver<H: HostTypes> {
fn resolve(&self, handle: LeaseAllocationHandle<H>) -> Option<LeaseAllocationRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct LeaseAllocationRecord<H: HostTypes> {
pub lease_source_handle: crate::user::state::ContextLeaseHandle<H>,
pub lease_cardinality: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedLeaseAllocation<'r, R: LeaseAllocationResolver<H>, H: HostTypes> {
handle: LeaseAllocationHandle<H>,
resolver: &'r R,
record: Option<LeaseAllocationRecord<H>>,
}
impl<'r, R: LeaseAllocationResolver<H>, H: HostTypes> ResolvedLeaseAllocation<'r, R, H> {
#[inline]
pub fn new(handle: LeaseAllocationHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> LeaseAllocationHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&LeaseAllocationRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: LeaseAllocationResolver<H>, H: HostTypes> LeaseAllocation<H>
for ResolvedLeaseAllocation<'r, R, H>
{
type LinearSite = NullLinearSite<H>;
fn lease_target(&self) -> &[Self::LinearSite] {
&[]
}
type ContextLease = crate::user::state::NullContextLease<H>;
fn lease_source(&self) -> &Self::ContextLease {
&<crate::user::state::NullContextLease<H>>::ABSENT
}
fn lease_cardinality(&self) -> u64 {
match &self.record {
Some(r) => r.lease_cardinality,
None => 0,
}
}
}
impl<'r, R: LeaseAllocationResolver<H>, H: HostTypes> ResolvedLeaseAllocation<'r, R, H> {
#[inline]
pub fn resolve_lease_source<'r2, R2: crate::user::state::ContextLeaseResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::user::state::ResolvedContextLease<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::user::state::ResolvedContextLease::new(
record.lease_source_handle,
r,
))
}
}
#[derive(Debug)]
pub struct AffineSiteHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for AffineSiteHandle<H> {}
impl<H: HostTypes> Clone for AffineSiteHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for AffineSiteHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for AffineSiteHandle<H> {}
impl<H: HostTypes> core::hash::Hash for AffineSiteHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> AffineSiteHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait AffineSiteResolver<H: HostTypes> {
fn resolve(&self, handle: AffineSiteHandle<H>) -> Option<AffineSiteRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct AffineSiteRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedAffineSite<'r, R: AffineSiteResolver<H>, H: HostTypes> {
handle: AffineSiteHandle<H>,
resolver: &'r R,
record: Option<AffineSiteRecord<H>>,
}
impl<'r, R: AffineSiteResolver<H>, H: HostTypes> ResolvedAffineSite<'r, R, H> {
#[inline]
pub fn new(handle: AffineSiteHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> AffineSiteHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&AffineSiteRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: AffineSiteResolver<H>, H: HostTypes> crate::bridge::partition::SiteIndex<H>
for ResolvedAffineSite<'r, R, H>
{
fn site_position(&self) -> u64 {
0
}
fn site_state(&self) -> u64 {
0
}
type SiteIndexTarget = crate::bridge::partition::NullSiteIndex<H>;
fn ancilla_site(&self) -> &Self::SiteIndexTarget {
&<crate::bridge::partition::NullSiteIndex<H>>::ABSENT
}
}
impl<'r, R: AffineSiteResolver<H>, H: HostTypes> AffineSite<H> for ResolvedAffineSite<'r, R, H> {}