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§
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
Required Methods§
sourcefn iter_sources(&self) -> IntoIter<(NodeIndex, Self::Source)>
fn iter_sources(&self) -> IntoIter<(NodeIndex, Self::Source)>
Iterate the links and its source reflection
sourcefn iter_links(
&self,
link: Self::LinkMirror,
) -> Box<dyn Iterator<Item = NodeIndex> + '_>
fn iter_links( &self, link: Self::LinkMirror, ) -> Box<dyn Iterator<Item = NodeIndex> + '_>
Iterate the linked node of the specified link
sourcefn modify_link(
&mut self,
source: Self::Source,
old_idx: NodeIndex,
new_idx: NodeIndex,
) -> (bool, bool)
fn modify_link( &mut self, source: Self::Source, old_idx: NodeIndex, new_idx: NodeIndex, ) -> (bool, bool)
Modify a link by source, return (remove_sucess, add_success)
sourcefn add_link(&mut self, link: Self::LinkMirror, target: NodeIndex) -> bool
fn add_link(&mut self, link: Self::LinkMirror, target: NodeIndex) -> bool
Add a link, designed for bidirectional links, return true if the link is actually added
sourcefn remove_link(&mut self, link: Self::LinkMirror, target: NodeIndex) -> bool
fn remove_link(&mut self, link: Self::LinkMirror, target: NodeIndex) -> bool
Remove a link, designed for bidirectional links, return true if the link is actually removed
sourcefn link_types() -> &'static [LinkType]
fn link_types() -> &'static [LinkType]
Get the types of the links
sourcefn link_mirrors() -> &'static [Self::LinkMirror]
fn link_mirrors() -> &'static [Self::LinkMirror]
Get a mirror reflecting the links
sourcefn link_names() -> &'static [&'static str]
fn link_names() -> &'static [&'static str]
Get the name of the links
sourcefn get_links_by_name(
&self,
name: &'static str,
) -> Box<dyn Iterator<Item = NodeIndex> + '_>
fn get_links_by_name( &self, name: &'static str, ) -> Box<dyn Iterator<Item = NodeIndex> + '_>
Get the links by name
sourcefn get_links_by_group(&self, name: &'static str) -> Vec<NodeIndex>
fn get_links_by_group(&self, name: &'static str) -> Vec<NodeIndex>
Get the links by group name
sourcefn data_names() -> &'static [&'static str]
fn data_names() -> &'static [&'static str]
Get the name of the data
sourcefn data_ref_by_name<T: Any>(&self, name: &'static str) -> Option<&T>
fn data_ref_by_name<T: Any>(&self, name: &'static str) -> Option<&T>
Try to get the reference of a data by name
sourcefn to_source(input: Self::LinkMirror) -> Self::Source
fn to_source(input: Self::LinkMirror) -> Self::Source
Convert Source to LinkMirror
sourcefn to_link_mirror(input: Self::Source) -> Self::LinkMirror
fn to_link_mirror(input: Self::Source) -> Self::LinkMirror
Convert LinkMirror to Source
sourcefn to_link_or_groups(input: Self::LinkMirror) -> &'static [Self::LoGMirror]
fn to_link_or_groups(input: Self::LinkMirror) -> &'static [Self::LoGMirror]
Get the groups a link belongs, include self
Object Safety§
This trait is not object safe.