Handle

Trait Handle 

Source
pub trait Handle:
    Clone
    + Copy
    + Debug
    + PartialEq
    + Eq
    + PartialOrd
    + Ord
    + Hash
    + DataSize
    + Sealed {
    // Required methods
    fn new(intid: usize) -> Self;
    fn as_usize(&self) -> usize;

    // Provided method
    fn reindex(&self, gaps: &[(Self, isize)]) -> Self { ... }
}
Expand description

The handle trait is implemented for various handle types. They have in common that refer to the internal id of a Storable item in a struct implementing StoreFor by index. Types implementing this are lightweight and do not borrow anything, they can be passed and copied freely. This is a sealed trait, not implementable outside this crate.

Required Methods§

Source

fn new(intid: usize) -> Self

Create a new handle for an internal ID. You shouldn’t need to use this as handles will always be generated for you by higher-level functions. In fact, creating them yourself like this should be considered dangerous!

Source

fn as_usize(&self) -> usize

Returns the internal index for this handle.

Provided Methods§

Source

fn reindex(&self, gaps: &[(Self, isize)]) -> Self

Low-level method to compute a new handle based on a list of gaps, used by reindexers. There is usually no reason to call this yourself.

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.

Implementors§