orx_selfref_col/references/
node_idx_error.rs

1use core::fmt::{Debug, Display};
2
3/// Error cases of an invalid node index.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum NodeIdxError {
6    /// RemovedNode => Referenced node is removed from the collection.
7    /// Node index can only be used if the corresponding node still belongs to the collection.
8    RemovedNode,
9    /// OutOfBounds => Node index is does not point to the current nodes of the collection.
10    /// This might be due to either of the following:
11    /// * the index is being used to access a collection which is different than which it was created for,
12    /// * the node that the index is pointing to does not belong to the collection any more due to
13    ///   shrinking of the collection.
14    OutOfBounds,
15    /// ReorganizedCollection => Nodes of the containing collection is re-organized in order to reclaim memory of closed nodes.
16    /// Such a reorganization happens:
17    /// * after a node removal if the utilization level drops below a threshold on default self-reorganizing memory policies,
18    /// * after every removal if the always-reclaim memory is used,
19    /// * only if the `reclaim_closed_nodes()` is manually called when never-reclaim policy is used,
20    ///   * note that in this case indices are never implicitly invalidated.
21    ReorganizedCollection,
22}
23
24impl Display for NodeIdxError {
25    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
26        <NodeIdxError as Debug>::fmt(self, f)
27    }
28}