pub struct OutputNode {
pub name: String,
pub entry_type: EntryType,
pub text: Option<String>,
pub cells: Vec<String>,
pub children: Vec<OutputNode>,
}Expand description
A node in the output tree.
Nodes can carry text, tabular cells, and nested children. This is the building block for all structured output.
§Examples
Simple text output (echo):
let node = OutputNode::text("hello world");File listing (ls):
let node = OutputNode::new("file.txt").with_entry_type(EntryType::File);Table row (ls -l):
let node = OutputNode::new("file.txt")
.with_cells(vec!["drwxr-xr-x".into(), "4096".into()])
.with_entry_type(EntryType::Directory);Tree node with children:
let child = OutputNode::new("main.rs").with_entry_type(EntryType::File);
let parent = OutputNode::new("src")
.with_entry_type(EntryType::Directory)
.with_children(vec![child]);Fields§
§name: StringPrimary identifier (filename, key, label).
entry_type: EntryTypeRendering hint (colors, icons).
text: Option<String>Text content (for echo, cat, exec).
cells: Vec<String>Additional columns (for ls -l, ps, env).
children: Vec<OutputNode>Child nodes (for tree, find).
Implementations§
Source§impl OutputNode
impl OutputNode
Sourcepub fn with_entry_type(self, entry_type: EntryType) -> Self
pub fn with_entry_type(self, entry_type: EntryType) -> Self
Set the entry type for rendering hints.
Sourcepub fn with_cells(self, cells: Vec<String>) -> Self
pub fn with_cells(self, cells: Vec<String>) -> Self
Set additional columns for tabular output.
Sourcepub fn with_children(self, children: Vec<OutputNode>) -> Self
pub fn with_children(self, children: Vec<OutputNode>) -> Self
Set child nodes for tree output.
Sourcepub fn is_text_only(&self) -> bool
pub fn is_text_only(&self) -> bool
Check if this is a text-only node.
Sourcepub fn has_children(&self) -> bool
pub fn has_children(&self) -> bool
Check if this node has children.
Sourcepub fn display_name(&self) -> &str
pub fn display_name(&self) -> &str
Get the display name, potentially with text content.
Trait Implementations§
Source§impl Clone for OutputNode
impl Clone for OutputNode
Source§fn clone(&self) -> OutputNode
fn clone(&self) -> OutputNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OutputNode
impl Debug for OutputNode
Source§impl Default for OutputNode
impl Default for OutputNode
Source§fn default() -> OutputNode
fn default() -> OutputNode
Returns the “default value” for a type. Read more
Source§impl PartialEq for OutputNode
impl PartialEq for OutputNode
Source§impl Serialize for OutputNode
impl Serialize for OutputNode
impl StructuralPartialEq for OutputNode
Auto Trait Implementations§
impl Freeze for OutputNode
impl RefUnwindSafe for OutputNode
impl Send for OutputNode
impl Sync for OutputNode
impl Unpin for OutputNode
impl UnwindSafe for OutputNode
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