Skip to main content

AllocationSnapshot

Struct AllocationSnapshot 

Source
pub struct AllocationSnapshot {
    pub num_nodes: u64,
    pub registry: ResourceRegistry<u64, u64>,
    pub budget: Budget,
}
Expand description

An allocation snapshot: the accepted node set plus the running cost / budget figures, over a node universe 0..num_nodes bounded by capacity.

Fields§

§num_nodes: u64

|Nodes|: the node universe is the index range 0..num_nodes.

§registry: ResourceRegistry<u64, u64>

ResourceRegistry component mapping accepted nodes to their costs.

§budget: Budget

Budget component charged by the registered costs.

Implementations§

Source§

impl AllocationSnapshot

Source

pub fn new(capacity: u64, num_nodes: u64) -> AllocationSnapshot

Construct the empty snapshot: nothing accepted, full budget remaining. Realises the TLA+ Init predicate and establishes both invariants.

Source

pub fn contains_exec(&self, n: u64) -> bool

Executable membership test; links to the contains spec so callers can discharge the n ∉ accepted precondition of accept_node.

Source

pub fn accept_node(&mut self, n: u64, node_cost: u64)

Accept node n at cost node_cost. Realises the TLA+ AcceptNode action: its three guards are requires, and both invariants are re-established as ensures (the inductive preservation step).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.