Skip to main content

LayoutIndex

Trait LayoutIndex 

Source
pub trait LayoutIndex:
    LayoutIndex
    + Copy
    + Eq
    + Ord
    + Debug
    + Display
    + Hash
    + Sized {
    const ZERO: Self;

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

Unsigned dense ID width usable by graph and hypergraph layouts and builders.

This is the single index-width contract for the whole substrate: it merges what oxgraph-csr and oxgraph-hyper-bcsr previously duplicated as CsrIndex/BcsrIndex. usize is included for native build-time indices; persisted widths additionally implement SnapshotWidth.

§Performance

Implementations perform checked conversions in O(1).

Required Associated Constants§

Source

const ZERO: Self

The additive identity for this width (the zero offset / first slot).

Required Methods§

Source

fn to_usize(self) -> Option<usize>

Converts this ID to usize when representable on the current target.

§Performance

This function is O(1).

Source

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

Converts a usize into this ID width when representable.

§Performance

This function is O(1).

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 LayoutIndex for u16

Source§

const ZERO: Self = 0

Source§

fn to_usize(self) -> Option<usize>

Source§

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

Source§

impl LayoutIndex for u32

Source§

const ZERO: Self = 0

Source§

fn to_usize(self) -> Option<usize>

Source§

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

Source§

impl LayoutIndex for u64

Source§

const ZERO: Self = 0

Source§

fn to_usize(self) -> Option<usize>

Source§

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

Source§

impl LayoutIndex for usize

Source§

const ZERO: Self = 0

Source§

fn to_usize(self) -> Option<usize>

Source§

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

Implementors§