Enum AdmissionPreview

Source
pub enum AdmissionPreview {
    Ready,
    ZeroCost,
    InsufficientCredits {
        cost: u32,
        credits: u32,
    },
    AliveLimit {
        alive: usize,
        limit: u16,
    },
    Pacing {
        cooldown: f64,
        recovery: f64,
    },
}
Expand description

A snapshot of whether a spawn can be admitted, or its first blocking reason.

Reasons follow the admission checks in order: zero cost, insufficient credits, alive limit, then pacing. Pacing reports both concurrent timers. A preview does not reserve credits or an alive slot; call EncounterDirector::admit after validating the spawn location. See EncounterDirector::preview for an example.

Variants§

§

Ready

The request can be admitted immediately.

§

ZeroCost

Spawn costs must be nonzero, including when the budget is exhausted.

§

InsufficientCredits

The fixed encounter budget cannot pay this request.

Fields

§cost: u32

Requested spawn cost.

§credits: u32

Unspent encounter credits.

§

AliveLimit

The host-reported alive count has reached or exceeded the cap.

Fields

§alive: usize

Alive count supplied to the preview, without narrowing or clamping.

§limit: u16

Configured maximum alive count.

§

Pacing

Cost and alive checks pass, but at least one pacing timer is positive.

Fields

§cooldown: f64

Simulation seconds left in the first delay or post-admission interval.

§recovery: f64

Simulation seconds left in pressure-triggered recovery.

Implementations§

Source§

impl AdmissionPreview

Source

pub fn is_ready(self) -> bool

Whether admission would succeed at the time of the preview.

use ferravex_play::encounter::AdmissionPreview;
assert!(AdmissionPreview::Ready.is_ready());
assert!(!AdmissionPreview::ZeroCost.is_ready());
Source

pub fn next_available_in(self) -> Option<f64>

Simulation seconds until the current pacing gates open, if time alone can make this request admissible. Ready requests return Some(0.0).

Zero cost, insufficient credits and the alive limit return None: advancing time cannot change the cost, replenish the budget or predict an actor’s departure. Otherwise the wait is the maximum of the two timers, which drain concurrently. The f64 result preserves the director’s timer precision.

This is a snapshot, not a reservation or a wall-clock deadline. Future admissions, alive-count changes or newly triggered recovery can change availability. Advance on simulation ticks with the existing 0.25 second per-call limit, then preview again before admitting.

use ferravex_play::encounter::AdmissionPreview;
let wait = AdmissionPreview::Pacing { cooldown: 0.5, recovery: 1.0 };
assert_eq!(wait.next_available_in(), Some(1.0));
assert_eq!(AdmissionPreview::Ready.next_available_in(), Some(0.0));
assert_eq!(AdmissionPreview::AliveLimit { alive: 2, limit: 2 }
    .next_available_in(), None);

Trait Implementations§

Source§

impl Clone for AdmissionPreview

Source§

fn clone(&self) -> AdmissionPreview

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AdmissionPreview

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AdmissionPreview

Source§

fn eq(&self, other: &AdmissionPreview) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for AdmissionPreview

Source§

impl StructuralPartialEq for AdmissionPreview

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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.