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 new(name: impl Into<String>) -> OutputNode
pub fn new(name: impl Into<String>) -> OutputNode
Create a new node with a name.
Sourcepub fn text(content: impl Into<String>) -> OutputNode
pub fn text(content: impl Into<String>) -> OutputNode
Create a text-only node (for echo, cat, etc.).
Sourcepub fn with_entry_type(self, entry_type: EntryType) -> OutputNode
pub fn with_entry_type(self, entry_type: EntryType) -> OutputNode
Set the entry type for rendering hints.
Sourcepub fn with_cells(self, cells: Vec<String>) -> OutputNode
pub fn with_cells(self, cells: Vec<String>) -> OutputNode
Set additional columns for tabular output.
Sourcepub fn with_children(self, children: Vec<OutputNode>) -> OutputNode
pub fn with_children(self, children: Vec<OutputNode>) -> OutputNode
Set child nodes for tree output.
Sourcepub fn with_text(self, text: impl Into<String>) -> OutputNode
pub fn with_text(self, text: impl Into<String>) -> OutputNode
Set text content.
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, Error>
pub fn write_canonical( &self, w: &mut dyn Write, _budget: usize, ) -> Result<usize, Error>
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 · 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<OutputNode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<OutputNode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for OutputNode
impl PartialEq for OutputNode
Source§impl Serialize for OutputNode
impl Serialize for OutputNode
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq 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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.