pub struct Node {
pub id: NodeId,
pub label: String,
pub node_type: String,
pub node_kind: NodeKind,
pub children: Vec<Node>,
}Expand description
Domain model for a node in the navigation tree.
Node is the rich domain type used server-side.
Use NodeView for browser transfer.
Fields§
§id: NodeIdUnique hierarchical identifier.
label: StringHuman-readable display name.
node_type: StringConsumer-defined type tag (e.g. "folder", "document", "user").
node_kind: NodeKindWhether the node is a container or leaf.
children: Vec<Node>Immediate children (populated for in-memory trees).
Implementations§
Source§impl Node
impl Node
Sourcepub fn container(id: NodeId, label: String, node_type: &str) -> Self
pub fn container(id: NodeId, label: String, node_type: &str) -> Self
Construct a container node with no children.
Sourcepub fn root(id: NodeId, label: String, node_type: &str) -> Self
pub fn root(id: NodeId, label: String, node_type: &str) -> Self
Convenience: root-level container (wraps container).
Sourcepub fn with_child(self, child: Node) -> Self
pub fn with_child(self, child: Node) -> Self
Builder: add a child node and return self.
Sourcepub fn with_children(self, children: Vec<Node>) -> Self
pub fn with_children(self, children: Vec<Node>) -> Self
Builder: add multiple children.
Sourcepub fn leaf_nodes(&self) -> Vec<&Node>
pub fn leaf_nodes(&self) -> Vec<&Node>
All leaf nodes in this subtree (depth-first).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Node
impl<'de> Deserialize<'de> for Node
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromFormData for Twhere
T: DeserializeOwned,
impl<T> FromFormData for Twhere
T: DeserializeOwned,
Source§fn from_event(ev: &Event) -> Result<T, FromFormDataError>
fn from_event(ev: &Event) -> Result<T, FromFormDataError>
Tries to deserialize the data, given only the
submit event.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.