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:
| Target | usize | u32 | u16 |
|---|---|---|---|
thumbv7em-none-eabihf (32-bit) | 80 + 16 | 80 + 16 | 76 + 16 |
x86_64 | 96 + 24 | 80 + 16 | 76 + 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§
Required Methods§
Sourcefn from_usize(value: usize) -> Option<Self>
fn from_usize(value: usize) -> Option<Self>
Converts value, or None if it does not fit.
Sourcefn to_usize(self) -> usize
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.
Sourcefn saturating_dec(self) -> Self
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".