pub enum OutputMode {
Auto,
Term,
Text,
TermDebug,
Json,
Yaml,
Xml,
Csv,
}Expand description
Controls how output is rendered.
This determines whether ANSI escape codes are included in the output, or whether to output structured data formats like JSON.
§Variants
Auto- Detect terminal capabilities automatically (default behavior)Term- Always include ANSI escape codes (for terminal output)Text- Never include ANSI escape codes (plain text)TermDebug- Render style names as bracket tags for debuggingJson- Serialize data as JSON (skips template rendering)
§Example
use standout::{render_with_output, Theme, OutputMode};
use console::Style;
use serde::Serialize;
#[derive(Serialize)]
struct Data { message: String }
let theme = Theme::new().add("ok", Style::new().green());
let data = Data { message: "Hello".into() };
// Auto-detect (default)
let auto = render_with_output(
r#"[ok]{{ message }}[/ok]"#,
&data,
&theme,
OutputMode::Auto,
).unwrap();
// Force plain text
let plain = render_with_output(
r#"[ok]{{ message }}[/ok]"#,
&data,
&theme,
OutputMode::Text,
).unwrap();
assert_eq!(plain, "Hello");
// Debug mode - renders bracket tags
let debug = render_with_output(
r#"[ok]{{ message }}[/ok]"#,
&data,
&theme,
OutputMode::TermDebug,
).unwrap();
assert_eq!(debug, "[ok]Hello[/ok]");Variants§
Auto
Auto-detect terminal capabilities
Term
Always use ANSI escape codes (terminal output)
Text
Never use ANSI escape codes (plain text)
TermDebug
Debug mode: render style names as bracket tags [name]text[/name]
Json
Structured output: serialize data as JSON (skips template rendering)
Yaml
Structured output: serialize data as YAML (skips template rendering)
Xml
Structured output: serialize data as XML (skips template rendering)
Csv
Structured output: serialize flattened data as CSV (skips template rendering)
Implementations§
Source§impl OutputMode
impl OutputMode
Sourcepub fn should_use_color(&self) -> bool
pub fn should_use_color(&self) -> bool
Resolves the output mode to a concrete decision about whether to use color.
Autochecks terminal capabilitiesTermalways returnstrueTextalways returnsfalseTermDebugreturnsfalse(handled specially by apply methods)Jsonreturnsfalse(structured output, no ANSI codes)
Sourcepub fn is_debug(&self) -> bool
pub fn is_debug(&self) -> bool
Returns true if this is debug mode (bracket tags instead of ANSI).
Sourcepub fn is_structured(&self) -> bool
pub fn is_structured(&self) -> bool
Returns true if this is a structured output mode (JSON, etc.).
Structured modes serialize data directly instead of rendering templates.
Trait Implementations§
Source§impl Clone for OutputMode
impl Clone for OutputMode
Source§fn clone(&self) -> OutputMode
fn clone(&self) -> OutputMode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OutputMode
impl Debug for OutputMode
Source§impl Default for OutputMode
impl Default for OutputMode
Source§fn default() -> OutputMode
fn default() -> OutputMode
Source§impl PartialEq for OutputMode
impl PartialEq for OutputMode
impl Copy for OutputMode
impl Eq for OutputMode
impl StructuralPartialEq for OutputMode
Auto Trait Implementations§
impl Freeze for OutputMode
impl RefUnwindSafe for OutputMode
impl Send for OutputMode
impl Sync for OutputMode
impl Unpin for OutputMode
impl UnwindSafe for OutputMode
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§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.