Trait GenerationalId
pub trait GenerationalId: Copy + PartialEq {
// Required methods
fn new(index: u64, generation: u64) -> Self;
fn index(&self) -> usize;
fn generation(&self) -> u16;
fn null() -> Self;
fn is_null(&self) -> bool;
fn root() -> Self;
}
Expand description
A trait implemented by any generational id.
A generational id has an index and a generation. The index is used for accessing arrays and the generation is used to check if the id is still valid or alive.
Required Methods§
fn new(index: u64, generation: u64) -> Self
fn new(index: u64, generation: u64) -> Self
Creates a new generational id from an index and a generation.
fn index(&self) -> usize
fn index(&self) -> usize
Returns the index of the generational id.
This is used to access the data of the generational id inside of an array.
fn generation(&self) -> u16
fn generation(&self) -> u16
Returns the generation of the generational id.
This is used to determine whether this generational id is still valid.
fn null() -> Self
fn null() -> Self
Creates a null or invalid generational id.
A null id can be used as a place holder.
fn root() -> Self
fn root() -> Self
Returns the root id usually referring to the first id (e.g. Entity(0)).
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.