Trait ttgraph::TypedNode

source ·
pub trait TypedNode {
    type Source: Copy + Clone + Eq + PartialEq + Debug + Hash + PartialOrd + Ord + Sized + 'static;
    type LinkMirror: Copy + Clone + Eq + PartialEq + Debug + Hash + PartialOrd + Ord + Sized + 'static;
    type LoGMirror: Copy + Clone + Eq + PartialEq + Debug + Hash + PartialOrd + Ord + Sized + 'static;

Show 15 methods // Required methods fn iter_sources(&self) -> IntoIter<(NodeIndex, Self::Source)>; fn iter_links( &self, link: Self::LinkMirror, ) -> Box<dyn Iterator<Item = NodeIndex> + '_>; fn modify_link( &mut self, source: Self::Source, old_idx: NodeIndex, new_idx: NodeIndex, ) -> (bool, bool); fn add_link(&mut self, link: Self::LinkMirror, target: NodeIndex) -> bool; fn remove_link(&mut self, link: Self::LinkMirror, target: NodeIndex) -> bool; fn link_types() -> &'static [LinkType]; fn link_mirrors() -> &'static [Self::LinkMirror]; fn link_names() -> &'static [&'static str]; fn get_links_by_name( &self, name: &'static str, ) -> Box<dyn Iterator<Item = NodeIndex> + '_>; fn get_links_by_group(&self, name: &'static str) -> Vec<NodeIndex>; fn data_names() -> &'static [&'static str]; fn data_ref_by_name<T: Any>(&self, name: &'static str) -> Option<&T>; fn to_source(input: Self::LinkMirror) -> Self::Source; fn to_link_mirror(input: Self::Source) -> Self::LinkMirror; fn to_link_or_groups(input: Self::LinkMirror) -> &'static [Self::LoGMirror];
}
Expand description

A helper trait for the graph to trace all links in the nodes Intented to be automatically derived, may be unstable.

§Example

use ttgraph::*;
use std::collections::{HashSet, BTreeSet};
#[derive(TypedNode)]
struct SomeNode {
  a_link: NodeIndex,
  another_link: NodeIndex,
  vec_link: Vec<NodeIndex>,
  set_link: HashSet<NodeIndex>,
  bset_link: BTreeSet<NodeIndex>,
  other_data: usize
  // ...
}

Required Associated Types§

source

type Source: Copy + Clone + Eq + PartialEq + Debug + Hash + PartialOrd + Ord + Sized + 'static

source

type LinkMirror: Copy + Clone + Eq + PartialEq + Debug + Hash + PartialOrd + Ord + Sized + 'static

source

type LoGMirror: Copy + Clone + Eq + PartialEq + Debug + Hash + PartialOrd + Ord + Sized + 'static

Required Methods§

source

fn iter_sources(&self) -> IntoIter<(NodeIndex, Self::Source)>

Iterate the links and its source reflection

Iterate the linked node of the specified link

Modify a link by source, return (remove_sucess, add_success)

Add a link, designed for bidirectional links, return true if the link is actually added

Remove a link, designed for bidirectional links, return true if the link is actually removed

Get the types of the links

Get a mirror reflecting the links

Get the name of the links

Get the links by name

Get the links by group name

source

fn data_names() -> &'static [&'static str]

Get the name of the data

source

fn data_ref_by_name<T: Any>(&self, name: &'static str) -> Option<&T>

Try to get the reference of a data by name

source

fn to_source(input: Self::LinkMirror) -> Self::Source

Convert Source to LinkMirror

Convert LinkMirror to Source

Get the groups a link belongs, include self

Object Safety§

This trait is not object safe.

Implementors§