pub struct RichOutput { /* private fields */ }Expand description
The main facade for rich console output.
Provides methods for printing styled text, tables, panels, and other visual elements. Automatically adapts output based on the detected environment.
Implementations§
Source§impl RichOutput
impl RichOutput
Sourcepub fn new(mode: OutputMode) -> Self
pub fn new(mode: OutputMode) -> Self
Create a new RichOutput with the specified mode and default theme.
Sourcepub fn with_mode(mode: OutputMode) -> Self
pub fn with_mode(mode: OutputMode) -> Self
Create a new RichOutput with the specified mode.
Sourcepub fn builder() -> RichOutputBuilder
pub fn builder() -> RichOutputBuilder
Create a builder for custom configuration.
Sourcepub const fn mode(&self) -> OutputMode
pub const fn mode(&self) -> OutputMode
Get the current output mode.
Sourcepub fn set_mode(&mut self, mode: OutputMode)
pub fn set_mode(&mut self, mode: OutputMode)
Set the output mode.
Sourcepub const fn is_agent_mode(&self) -> bool
pub const fn is_agent_mode(&self) -> bool
Check if running in agent-friendly mode (plain text output).
Returns true if the output mode is Plain, which is the mode
used when an AI agent environment is detected or explicitly requested.
§Example
use fastapi_output::prelude::*;
let output = RichOutput::plain();
assert!(output.is_agent_mode());
let output = RichOutput::rich();
assert!(!output.is_agent_mode());Sourcepub const fn mode_name(&self) -> &'static str
pub const fn mode_name(&self) -> &'static str
Get the mode name as a string for logging/debugging.
Returns one of: "rich", "plain", or "minimal".
§Example
use fastapi_output::prelude::*;
let output = RichOutput::plain();
assert_eq!(output.mode_name(), "plain");Sourcepub const fn theme(&self) -> &FastApiTheme
pub const fn theme(&self) -> &FastApiTheme
Get the current theme.
Sourcepub fn set_theme(&mut self, theme: FastApiTheme)
pub fn set_theme(&mut self, theme: FastApiTheme)
Set the theme.
Sourcepub fn success(&self, message: &str)
pub fn success(&self, message: &str)
Print a success message.
In rich mode: Green checkmark with styled text.
In plain mode: [OK] message
Sourcepub fn error(&self, message: &str)
pub fn error(&self, message: &str)
Print an error message.
In rich mode: Red X with styled text.
In plain mode: [ERROR] message
Sourcepub fn warning(&self, message: &str)
pub fn warning(&self, message: &str)
Print a warning message.
In rich mode: Yellow warning symbol with styled text.
In plain mode: [WARN] message
Sourcepub fn info(&self, message: &str)
pub fn info(&self, message: &str)
Print an info message.
In rich mode: Blue info symbol with styled text.
In plain mode: [INFO] message
Sourcepub fn debug(&self, message: &str)
pub fn debug(&self, message: &str)
Print a debug message (only in non-minimal modes).
In rich mode: Gray text.
In plain mode: [DEBUG] message
In minimal mode: Nothing printed.
Sourcepub fn status(&self, kind: StatusKind, message: &str)
pub fn status(&self, kind: StatusKind, message: &str)
Print a status message with the given kind.
Sourcepub fn with_test_output<F: FnOnce()>(test: &TestOutput, f: F)
pub fn with_test_output<F: FnOnce()>(test: &TestOutput, f: F)
Run a closure with test output capture enabled.
Sourcepub fn global() -> RwLockReadGuard<'static, RichOutput>
pub fn global() -> RwLockReadGuard<'static, RichOutput>
Get the global RichOutput instance.
§Panics
Sourcepub fn global_mut() -> RwLockWriteGuard<'static, RichOutput>
pub fn global_mut() -> RwLockWriteGuard<'static, RichOutput>
Get mutable access to the global RichOutput instance.
Trait Implementations§
Source§impl Clone for RichOutput
impl Clone for RichOutput
Source§fn clone(&self) -> RichOutput
fn clone(&self) -> RichOutput
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more