[−][src]Struct libwispha::core::Tree
Wispha tree structure
Methods
impl Tree
[src]
impl Tree
[src]
pub fn insert_nodes_from_str(
&self,
node_str: &str,
recorded_file: PathBuf,
parent_and_given_name: Option<(NodePath, String)>,
preserved_keys: &Vec<&'static str>
) -> Result<Rc<RefCell<Node>>, Error>
[src]
&self,
node_str: &str,
recorded_file: PathBuf,
parent_and_given_name: Option<(NodePath, String)>,
preserved_keys: &Vec<&'static str>
) -> Result<Rc<RefCell<Node>>, Error>
Insert nodes from JSON string node_str
in recorded_file
to tree
.
If node_str
is the root of Wispha tree, parent_and_given_name
should be None
;
else parent
should be the node_str
's parent, given_name
should be the link node's name
impl Tree
[src]
pub fn new(config: &TreeConfig) -> Tree
[src]
pub fn root(&self) -> Option<Rc<RefCell<Node>>>
[src]
Get root. If the tree has no node, return None
.
pub fn config(&self) -> TreeConfig
[src]
pub fn get_node(&self, node_path: &NodePath) -> Option<Rc<RefCell<Node>>>
[src]
Get node from the node_path
pub fn insert_node(
&self,
node_path: NodePath,
node: Rc<RefCell<Node>>
) -> Option<Rc<RefCell<Node>>>
[src]
&self,
node_path: NodePath,
node: Rc<RefCell<Node>>
) -> Option<Rc<RefCell<Node>>>
Insert node with node_path
and node
.
If the node_path
has already existed, the node is updated, and the old one is returned.
pub fn get_node_path(&self, node: Rc<RefCell<Node>>) -> NodePath
[src]
Get the node path of node
in tree
pub fn get_path_buf(&self, node_path: &NodePath) -> Result<PathBuf, Error>
[src]
Get the os-related path of node
in tree
pub fn clear(&self)
[src]
Clear all the nodes in the tree
pub fn resolve_node<F>(
&self,
node_path: &NodePath,
resolve_handler: &F,
preserved_keys: &Vec<&'static str>
) -> Result<(), Error> where
F: Fn(&LinkNode) -> Result<(PathBuf, String), Box<dyn Error>>,
[src]
&self,
node_path: &NodePath,
resolve_handler: &F,
preserved_keys: &Vec<&'static str>
) -> Result<(), Error> where
F: Fn(&LinkNode) -> Result<(PathBuf, String), Box<dyn Error>>,
Resolve to make sure tree has a direct node value of key node_path
.
resolve_handler
does two things:
- Convert
link_node
'starget
to a node_str contains thetarget
's content - Check if a direct loop exists, i.e. the
link_node
'starget
is itsrecord_file
pub fn resolve_in_depth<F>(
&self,
node_path: &NodePath,
depth: usize,
resolve_handler: &F,
preserved_keys: &Vec<&'static str>
) -> Result<(), Error> where
F: Fn(&LinkNode) -> Result<(PathBuf, String), Box<dyn Error>>,
[src]
&self,
node_path: &NodePath,
depth: usize,
resolve_handler: &F,
preserved_keys: &Vec<&'static str>
) -> Result<(), Error> where
F: Fn(&LinkNode) -> Result<(PathBuf, String), Box<dyn Error>>,
Update the tree
's nodes
, starting from node_path
, with depth depth
, to direct node,
using resolve_handler
to convert from PathBuf
to Node
.
If this function returns Ok
, it means two things:
- The
node_path
does exist in the tree - The children of
node_path
indepth
(if exists) are of typeDirectNode
The node_path
itself's depth
is 0
resolve_handler
does two things:
- Convert
link_node
'starget
to a node_str contains thetarget
's content - Check if a direct loop exists, i.e. the
link_node
'starget
is itsrecord_file
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Tree
impl !Send for Tree
impl !Sync for Tree
impl Unpin for Tree
impl !UnwindSafe for Tree
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,