bcinr-cmca 26.10.11

CMCA-RDF deterministic substrate crate
Documentation
use super::{
    contract::Envelope,
    resource_envelope::{Allocation, ResourceEnvelope},
};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum InteropRefusal {
    Authority,
    Resource,
}
pub fn allocate_via_envelope(
    e: &Envelope<'_>,
    budget: &ResourceEnvelope,
    want: &Allocation,
) -> Result<Allocation, InteropRefusal> {
    if e.authority != "none" {
        return Err(InteropRefusal::Authority);
    }
    if !budget.admits(want) {
        return Err(InteropRefusal::Resource);
    }
    Ok(*want)
}