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.
All fields are always serialized (no skip_serializing_if) for predictable shape across JSON, postcard, and bincode formats.
text is Option
- None: this is a named entry (file listing, table row), not a text node
- Some(“”): this IS a text node whose content is empty (e.g.
echo "")
The is_text_only() method depends on this distinction.
Fields§
§name: StringPrimary identifier (filename, key, label).
entry_type: EntryTypeRendering hint (colors, icons).
text: Option<String>Text content (for echo, cat, exec).
Three-state semantics:
None— named entry (file listing, table row), not textSome("")— text node with empty content (e.g.,echo "")Some("x")— text node with content
is_text_only() returns true iff text is Some AND name/cells/children are empty.
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 estimated_byte_size(&self) -> usize
pub fn estimated_byte_size(&self) -> usize
Estimate brace-notation byte size without materializing.
Sourcepub fn write_canonical(&self, w: &mut dyn Write, budget: usize) -> Result<usize>
pub fn write_canonical(&self, w: &mut dyn Write, budget: usize) -> Result<usize>
Write brace-notation to a writer. Returns bytes written.
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
Source§impl<'de> Deserialize<'de> for OutputNodewhere
OutputNode: Default,
impl<'de> Deserialize<'de> for OutputNodewhere
OutputNode: Default,
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>,
impl Eq for OutputNode
Source§impl PartialEq for OutputNode
impl PartialEq for OutputNode
Source§fn eq(&self, other: &OutputNode) -> bool
fn eq(&self, other: &OutputNode) -> bool
self and other values to be equal, and is used by ==.