pub(crate) trait FlagEvent: Sized {
const MAXIMUM: u16;
// Required methods
fn to_index(self) -> u16;
fn from_index(flag: u16) -> Option<Self>;
}Expand description
A trait to indicate something that can be published with FlagPublisher.
Since the implementation of FlagPublisher requires that its events be
represented as small integers, this trait is mainly about converting to and
from those integers.
Required Associated Constants§
Sourceconst MAXIMUM: u16
const MAXIMUM: u16
The maximum allowed integer value that FlagEvent::to_index() can return
for this type.
This is limited to u16 because the FlagPublisher uses a vector of all
known flags, and sometimes iterates over the whole vector.
Required Methods§
Sourcefn to_index(self) -> u16
fn to_index(self) -> u16
Convert this event into an index.
For efficiency, indices should be small and densely packed.
Sourcefn from_index(flag: u16) -> Option<Self>
fn from_index(flag: u16) -> Option<Self>
Try to reconstruct an event from its index. Return None if the index is out-of-bounds.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.