Struct Tree

Source
pub struct Tree {
    pub root_id: NodeId,
    pub nodes: Vector<HashMap<NodeId, Arc<Node>>>,
    pub parent_map: HashMap<NodeId, NodeId>,
    /* private fields */
}

Fields§

§root_id: NodeId§nodes: Vector<HashMap<NodeId, Arc<Node>>>§parent_map: HashMap<NodeId, NodeId>

Implementations§

Source§

impl Tree

Source

pub fn get_shard_index(&self, id: &NodeId) -> usize

Source

pub fn get_shard_indices(&self, ids: &[&NodeId]) -> Vec<usize>

Source

pub fn get_shard_index_batch<'a>( &self, ids: &'a [&'a NodeId], ) -> Vec<(usize, &'a NodeId)>

Source

pub fn clear_shard_cache()

Source

pub fn contains_node(&self, id: &NodeId) -> bool

Source

pub fn get_node(&self, id: &NodeId) -> Option<Arc<Node>>

Source

pub fn get_parent_node(&self, id: &NodeId) -> Option<Arc<Node>>

Source

pub fn from(nodes: NodeEnum) -> Self

Source

pub fn new(root: Node) -> Self

Source

pub fn update_attr( &mut self, id: &NodeId, new_values: HashMap<String, Value>, ) -> PoolResult<()>

Source

pub fn update_node(&mut self, node: Node) -> PoolResult<()>

Source

pub fn add( &mut self, parent_id: &NodeId, nodes: Vec<NodeEnum>, ) -> PoolResult<()>

向树中添加新的节点及其子节点

§参数
  • nodes - 要添加的节点枚举,包含节点本身及其子节点
§返回值
  • Result<(), PoolError> - 如果添加成功返回 Ok(()), 否则返回错误
§错误
  • PoolError::ParentNotFound - 如果父节点不存在
Source

pub fn add_at_index( &mut self, parent_id: &NodeId, index: usize, node: &Node, ) -> PoolResult<()>

Source

pub fn add_node( &mut self, parent_id: &NodeId, nodes: &Vec<Node>, ) -> PoolResult<()>

Source

pub fn node(&mut self, key: &str) -> NodeRef<'_>

Source

pub fn mark(&mut self, key: &str) -> MarkRef<'_>

Source

pub fn attrs(&mut self, key: &str) -> AttrsRef<'_>

Source

pub fn children(&self, parent_id: &NodeId) -> Option<Vector<NodeId>>

Source

pub fn children_node(&self, parent_id: &NodeId) -> Option<Vector<Arc<Node>>>

Source

pub fn all_children( &self, parent_id: &NodeId, filter: Option<&dyn Fn(&Node) -> bool>, ) -> Option<NodeEnum>

Source

pub fn children_count(&self, parent_id: &NodeId) -> usize

Source

pub fn remove_mark_by_name( &mut self, id: &NodeId, mark_name: &str, ) -> PoolResult<()>

Source

pub fn get_marks(&self, id: &NodeId) -> Option<Vector<Mark>>

Source

pub fn remove_mark( &mut self, id: &NodeId, mark_types: &[String], ) -> PoolResult<()>

Source

pub fn add_mark(&mut self, id: &NodeId, marks: &Vec<Mark>) -> PoolResult<()>

Source

pub fn move_node( &mut self, source_parent_id: &NodeId, target_parent_id: &NodeId, node_id: &NodeId, position: Option<usize>, ) -> PoolResult<()>

Source

pub fn remove_node( &mut self, parent_id: &NodeId, nodes: Vec<NodeId>, ) -> PoolResult<()>

Source

pub fn remove_node_by_id(&mut self, node_id: &NodeId) -> PoolResult<()>

Source

pub fn remove_node_by_index( &mut self, parent_id: &NodeId, index: usize, ) -> PoolResult<()>

根据下标删除

Trait Implementations§

Source§

impl Clone for Tree

Source§

fn clone(&self) -> Tree

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Tree

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Index<&String> for Tree

Source§

type Output = Arc<Node>

The returned type after indexing.
Source§

fn index(&self, index: &NodeId) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<&str> for Tree

Source§

type Output = Arc<Node>

The returned type after indexing.
Source§

fn index(&self, index: &str) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl PartialEq for Tree

Source§

fn eq(&self, other: &Tree) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Tree

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Tree

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnwindSafe for Tree

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,