pub struct OutputData {
pub headers: Option<Vec<String>>,
pub root: Vec<OutputNode>,
}Expand description
Structured output data from a command.
This is the top-level structure for command output. It contains optional column headers and a list of root nodes.
headers is Option<Vec
§Rendering Rules
| Structure | Interactive | Piped/Model |
|---|---|---|
Single node with text | Print text | Print text |
Flat nodes, name only | Multi-column, colored | One per line |
Flat nodes with cells | Aligned table | TSV or names only |
Nested children | Box-drawing tree | Brace notation |
Fields§
§headers: Option<Vec<String>>Column headers (optional, for table output).
root: Vec<OutputNode>Top-level nodes.
Implementations§
Source§impl OutputData
impl OutputData
Sourcepub fn new() -> OutputData
pub fn new() -> OutputData
Create new empty output data.
Sourcepub fn text(content: impl Into<String>) -> OutputData
pub fn text(content: impl Into<String>) -> OutputData
Create output data with a single text node.
This is the simplest form for commands like echo.
Sourcepub fn nodes(nodes: Vec<OutputNode>) -> OutputData
pub fn nodes(nodes: Vec<OutputNode>) -> OutputData
Create output data with named nodes (for ls, etc.).
Sourcepub fn table(headers: Vec<String>, nodes: Vec<OutputNode>) -> OutputData
pub fn table(headers: Vec<String>, nodes: Vec<OutputNode>) -> OutputData
Create output data with headers and nodes (for ls -l, ps, etc.).
Sourcepub fn with_headers(self, headers: Vec<String>) -> OutputData
pub fn with_headers(self, headers: Vec<String>) -> OutputData
Set column headers.
Sourcepub fn is_simple_text(&self) -> bool
pub fn is_simple_text(&self) -> bool
Check if this output is simple text (single text-only node).
Sourcepub fn is_tabular(&self) -> bool
pub fn is_tabular(&self) -> bool
Check if this output has tabular data (nodes with cells).
Sourcepub fn to_canonical_string(&self) -> String
pub fn to_canonical_string(&self) -> String
Convert to canonical string output (for pipes).
This produces a simple string representation suitable for piping to other commands:
- Text nodes: their text content
- Named nodes: names joined by newlines
- Tabular nodes (name + cells): TSV format (name\tcell1\tcell2…)
- Nested nodes: brace notation
Sourcepub fn to_json(&self) -> Value
pub fn to_json(&self) -> Value
Serialize to a JSON value for --json flag handling.
Bare data, no envelope — optimized for jq patterns.
| Structure | JSON |
|---|---|
| Simple text | "hello world" |
| Flat list (names only) | ["file1", "file2"] |
| Table (headers + cells) | [{"col1": "v1", ...}, ...] |
| Tree (nested children) | {"dir": {"file": null}} |
Trait Implementations§
Source§impl Clone for OutputData
impl Clone for OutputData
Source§fn clone(&self) -> OutputData
fn clone(&self) -> OutputData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OutputData
impl Debug for OutputData
Source§impl Default for OutputData
impl Default for OutputData
Source§fn default() -> OutputData
fn default() -> OutputData
Source§impl<'de> Deserialize<'de> for OutputDatawhere
OutputData: Default,
impl<'de> Deserialize<'de> for OutputDatawhere
OutputData: Default,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<OutputData, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<OutputData, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for OutputData
impl PartialEq for OutputData
Source§impl Serialize for OutputData
impl Serialize for OutputData
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 OutputData
impl StructuralPartialEq for OutputData
Auto Trait Implementations§
impl Freeze for OutputData
impl RefUnwindSafe for OutputData
impl Send for OutputData
impl Sync for OutputData
impl Unpin for OutputData
impl UnsafeUnpin for OutputData
impl UnwindSafe for OutputData
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.