pub trait TerminalManager<'id, N, ET, const TERMINALS: usize>: Sized {
type TerminalNode: Eq + Hash;
type TerminalNodeRef<'a>: Borrow<Self::TerminalNode> + Copy
where Self: 'a;
type Iterator<'a>: Iterator<Item = Edge<'id, N, ET>>
where Self: 'a;
// Required methods
fn with_capacity(capacity: u32) -> Self;
fn len(&self) -> usize;
unsafe fn get_terminal(&self, id: usize) -> Self::TerminalNodeRef<'_>;
unsafe fn retain(&self, id: usize);
unsafe fn release(&self, id: usize);
fn get_edge(
&self,
terminal: Self::TerminalNode,
) -> AllocResult<Edge<'id, N, ET>>;
fn iter<'a>(&'a self) -> Self::Iterator<'a>
where Self: 'a;
fn gc(&self) -> u32;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Manager for terminal nodes
Several methods of this trait require valid terminal node IDs. All Edges
referencing terminal nodes “contain” valid terminal node IDs. These IDs can
be derived from the edges by stripping the tags (which is an implementation
detail of the manager module). Edges referencing terminal nodes are
created by the get_edge() and
iter() methods via
Edge::from_terminal_id().
Required Associated Types§
Sourcetype TerminalNode: Eq + Hash
type TerminalNode: Eq + Hash
The terminal node type
Sourcetype TerminalNodeRef<'a>: Borrow<Self::TerminalNode> + Copy
where
Self: 'a
type TerminalNodeRef<'a>: Borrow<Self::TerminalNode> + Copy where Self: 'a
References to Self::TerminalNodes
Should either be a &'a Self::Terminal or just Self::Terminal. The
latter is useful for the StaticTerminalManager which doesn’t
actually store nodes but performs the mapping between edges and terminal
nodes on the fly.
Required Methods§
Sourcefn with_capacity(capacity: u32) -> Self
fn with_capacity(capacity: u32) -> Self
Create a new TerminalManager
capacity is a hint on the maximum number of terminal nodes and may be
less than TERMINALS. If the number of terminals is constant, the
implementation may simply ignore this parameter.
Sourceunsafe fn get_terminal(&self, id: usize) -> Self::TerminalNodeRef<'_>
unsafe fn get_terminal(&self, id: usize) -> Self::TerminalNodeRef<'_>
Sourceunsafe fn retain(&self, id: usize)
unsafe fn retain(&self, id: usize)
Increment the reference counter of the terminal id
§Safety
id must be a valid terminal node ID for this terminal manager.
Sourceunsafe fn release(&self, id: usize)
unsafe fn release(&self, id: usize)
Decrement the reference counter of the terminal id
§Safety
id must be a valid terminal node ID for this terminal manager.
Sourcefn get_edge(
&self,
terminal: Self::TerminalNode,
) -> AllocResult<Edge<'id, N, ET>>
fn get_edge( &self, terminal: Self::TerminalNode, ) -> AllocResult<Edge<'id, N, ET>>
Add a terminal to this manager (if it does not already exist) and return
an Edge pointing to it
Provided Methods§
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.