use crate::bounded::Capped;
use crate::identity::{self, ClosureId, Identity, OwnerIdentity, PlanId, Provenance};
use crate::kind::{Destination, Role};
use crate::plan::Membership;
use crate::render::RenderedProjection;
use crate::token::GeneratedTree;
#[path = "type_guard.rs"]
mod guard;
pub const CLOSURE_ISSUE_LIMIT: usize = 64;
#[must_use = "carried tokens are a delivery's bytes and the digest of exactly those bytes"]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct CarriedTokens {
tree: GeneratedTree,
digest: Identity<identity::OutputBytes>,
}
#[must_use = "a delivery either carries proved tokens or states that nothing was planned into it"]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum PartitionCargo {
NothingPlanned,
Carried(CarriedTokens),
}
#[must_use = "a partitioned emission is what one proved rendering delivers, split by delivery"]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PartitionedEmission {
declaration_site: PartitionCargo,
test_carrier: PartitionCargo,
bench_carrier: PartitionCargo,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ClosureIssue<R: Role> {
MemberMissing {
role: R,
},
MemberUnplanned {
role: R,
},
MemberDuplicated {
role: R,
observed: u32,
},
OriginOrphan {
role: R,
},
DigestMismatch {
role: R,
},
SemanticKeyMismatch {
role: R,
},
MaterializationMismatch {
role: R,
},
MemberPlannedTwice {
role: R,
observed: u32,
},
MembershipDisagreement {
role: R,
},
ReconstructionEmpty,
ReconstructionUndeclarable {
observed: u32,
},
JoinedTreeUnbounded {
destination: Destination,
},
ArtifactAddressDoubled {
role: R,
address: OwnerIdentity,
},
ArtifactAddressAbsent {
role: R,
},
}
#[must_use = "a closure refusal carries every way the rendering and the plan disagree"]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ClosureError<R: Role> {
body: Capped<ClosureIssue<R>, CLOSURE_ISSUE_LIMIT>,
}
#[must_use = "a closure is the proof that what was rendered is what was planned"]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Closure<R: Role> {
plan: PlanId,
reconstructed: Membership<R>,
rendered: RenderedProjection<R>,
emission: PartitionedEmission,
identity: ClosureId,
provenance: Provenance,
}