Skip to main content

Index

Trait Index 

Source
pub trait Index:
    Sealed
    + Copy
    + Eq
    + Ord
    + Hash
    + Debug
    + 'static {
    const ZERO: Self;

    // Required methods
    fn from_usize(value: usize) -> Option<Self>;
    fn to_usize(self) -> usize;
    fn saturating_dec(self) -> Self;
}
Expand description

Unsigned integer type a Dispatcher stores point and entry handles in: u16, u32 or usize (the default).

Public handles stay TimePoint(usize); the index type only sets the width of the dispatcher’s internal arrays (adjacency targets, range offsets, precedence counters, activation links). A network fits iff its point count and its entry count (2 * edges + waits) are both at most the type’s maximum value, so that every index and every range offset, including the one-past-the-end offset, is representable. Loading a network that does not fit fails with DispatchError::IndexTypeTooSmall. Choosing capacities N, E <= MAX rules that out statically.

§Memory

Measured size_of per point and per entry capacity slot:

Targetusizeu32u16
thumbv7em-none-eabihf (32-bit)80 + 1680 + 1676 + 16
x86_6496 + 2480 + 1676 + 16

Entries and windows hold i64 ticks and are 8-byte aligned, so on 32-bit targets a narrow index saves only the per-point offsets and counters.

The trait is sealed: it cannot be implemented outside this crate.

Required Associated Constants§

Source

const ZERO: Self

The value zero, for const initialisers.

Required Methods§

Source

fn from_usize(value: usize) -> Option<Self>

Converts value, or None if it does not fit.

Source

fn to_usize(self) -> usize

Widens to usize.

Exact for every value obtained from Index::from_usize; on targets where usize is narrower than Self other values map to usize::MAX.

Source

fn saturating_dec(self) -> Self

Subtracts one, staying at zero.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Index for u16

Source§

const ZERO: Self = 0

Source§

fn from_usize(value: usize) -> Option<Self>

Source§

fn to_usize(self) -> usize

Source§

fn saturating_dec(self) -> Self

Source§

impl Index for u32

Source§

const ZERO: Self = 0

Source§

fn from_usize(value: usize) -> Option<Self>

Source§

fn to_usize(self) -> usize

Source§

fn saturating_dec(self) -> Self

Source§

impl Index for usize

Source§

const ZERO: Self = 0

Source§

fn from_usize(value: usize) -> Option<Self>

Source§

fn to_usize(self) -> usize

Source§

fn saturating_dec(self) -> Self

Implementors§