Skip to main content

RichOutput

Struct RichOutput 

Source
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

Source

pub fn new(mode: OutputMode) -> Self

Create a new RichOutput with the specified mode and default theme.

Source

pub fn with_mode(mode: OutputMode) -> Self

Create a new RichOutput with the specified mode.

Source

pub fn auto() -> Self

Create a new RichOutput with auto-detected mode.

Source

pub fn rich() -> Self

Create a new RichOutput with rich mode (for humans).

Source

pub fn plain() -> Self

Create a new RichOutput with plain mode (for agents).

Source

pub fn builder() -> RichOutputBuilder

Create a builder for custom configuration.

Source

pub const fn mode(&self) -> OutputMode

Get the current output mode.

Source

pub fn set_mode(&mut self, mode: OutputMode)

Set the output mode.

Source

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());
Source

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");
Source

pub const fn theme(&self) -> &FastApiTheme

Get the current theme.

Source

pub fn set_theme(&mut self, theme: FastApiTheme)

Set the theme.

Source

pub fn success(&self, message: &str)

Print a success message.

In rich mode: Green checkmark with styled text. In plain mode: [OK] message

Source

pub fn error(&self, message: &str)

Print an error message.

In rich mode: Red X with styled text. In plain mode: [ERROR] message

Source

pub fn warning(&self, message: &str)

Print a warning message.

In rich mode: Yellow warning symbol with styled text. In plain mode: [WARN] message

Source

pub fn info(&self, message: &str)

Print an info message.

In rich mode: Blue info symbol with styled text. In plain mode: [INFO] message

Source

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.

Source

pub fn status(&self, kind: StatusKind, message: &str)

Print a status message with the given kind.

Source

pub fn rule(&self, title: Option<&str>)

Print a horizontal rule/divider.

Source

pub fn panel(&self, content: &str, title: Option<&str>)

Print content in a panel/box.

Source

pub fn print(&self, text: &str)

Print raw text.

Source

pub fn with_test_output<F: FnOnce()>(test: &TestOutput, f: F)

Run a closure with test output capture enabled.

Source

pub fn global() -> RwLockReadGuard<'static, RichOutput>

Get the global RichOutput instance.

§Panics
Source

pub fn global_mut() -> RwLockWriteGuard<'static, RichOutput>

Get mutable access to the global RichOutput instance.

Trait Implementations§

Source§

impl Clone for RichOutput

Source§

fn clone(&self) -> RichOutput

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RichOutput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RichOutput

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.