Skip to main content

TreeNode

Trait TreeNode 

Source
pub trait TreeNode: From<Self::Model> {
    type Model: Model;
    type Id: ?Sized + Eq + Ord + Debug + Clone + Hash;

    // Required methods
    fn id(&self) -> Self::Id;
    fn sequence(&self) -> i32;
    fn parent_id(&self) -> Self::Id;
    fn children(&self) -> &Vec<NodeRef<Self>>;
    fn children_mut(&mut self) -> &mut Vec<NodeRef<Self>>;

    // Provided method
    fn sort_children(&mut self) { ... }
}
Expand description

A trait for models that can be used as tree nodes.

Required Associated Types§

Source

type Model: Model

The reference model.

Source

type Id: ?Sized + Eq + Ord + Debug + Clone + Hash

The unique identifier of the node.

Required Methods§

Source

fn id(&self) -> Self::Id

Returns the unique identifier of the node.

Source

fn sequence(&self) -> i32

Returns the sequence number (ordering) of the node.

Source

fn parent_id(&self) -> Self::Id

Returns the parent identifier of the node.

Source

fn children(&self) -> &Vec<NodeRef<Self>>

Returns a reference to the vector containing the child references.

Source

fn children_mut(&mut self) -> &mut Vec<NodeRef<Self>>

Returns a mutable reference to the vector containing the child references.

Provided Methods§

Source

fn sort_children(&mut self)

Sort children by position, breaking ties by their stable identifiers.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§