pub struct FastMcpConsole { /* private fields */ }Expand description
FastMCP console for rich output to stderr.
This type centralizes rich-vs-plain output behavior and exposes convenience methods for printing tables, panels, and styled text.
§Example
use fastmcp_console::console::FastMcpConsole;
use rich_rust::prelude::Style;
let console = FastMcpConsole::new();
console.print_styled("Server started", Style::new().bold());Implementations§
Source§impl FastMcpConsole
impl FastMcpConsole
Sourcepub fn with_enabled(enabled: bool) -> Self
pub fn with_enabled(enabled: bool) -> Self
Create with explicit enable/disable
Sourcepub fn with_writer<W: Write + Send + 'static>(writer: W, enabled: bool) -> Self
pub fn with_writer<W: Write + Send + 'static>(writer: W, enabled: bool) -> Self
Create with custom writer (for testing)
Sourcepub fn theme(&self) -> &FastMcpTheme
pub fn theme(&self) -> &FastMcpTheme
Get the theme used for standard styling.
Sourcepub fn print(&self, content: &str)
pub fn print(&self, content: &str)
Print trusted styled markup (auto-detects markup).
This method does not sanitize terminal controls or secrets. Use
Self::print_untrusted for any peer-, user-, or network-controlled
value.
Sourcepub fn print_plain(&self, text: &str)
pub fn print_plain(&self, text: &str)
Print trusted plain text (no markup processing ever).
Disabling markup does not make terminal control sequences safe. Use
Self::print_untrusted for untrusted values.
Sourcepub fn print_untrusted(&self, text: &str)
pub fn print_untrusted(&self, text: &str)
Sanitize, redact, bound, and print an untrusted value as plain text.
Sourcepub fn render<R: Renderable>(&self, renderable: &R)
pub fn render<R: Renderable>(&self, renderable: &R)
Print a renderable.
Sourcepub fn render_or<F>(&self, render_op: F, plain_fallback: &str)
pub fn render_or<F>(&self, render_op: F, plain_fallback: &str)
Print a renderable with a trusted plain-text fallback closure.
Use Self::render_or_untrusted when the fallback is not trusted.
Sourcepub fn render_or_untrusted<F>(&self, render_op: F, plain_fallback: &str)
pub fn render_or_untrusted<F>(&self, render_op: F, plain_fallback: &str)
Print a renderable with a sanitized untrusted plain-text fallback.
Sourcepub fn rule(&self, title: Option<&str>)
pub fn rule(&self, title: Option<&str>)
Print a horizontal rule with an optional trusted title.
Use Self::rule_untrusted for an untrusted title.
Sourcepub fn rule_untrusted(&self, title: &str)
pub fn rule_untrusted(&self, title: &str)
Print a horizontal rule after sanitizing an untrusted title.
Sourcepub fn print_styled(&self, text: &str, style: Style)
pub fn print_styled(&self, text: &str, style: Style)
Print trusted text with a specific style.
Use Self::print_untrusted_styled for an untrusted value.
Sourcepub fn print_untrusted_styled(&self, text: &str, style: Style)
pub fn print_untrusted_styled(&self, text: &str, style: Style)
Sanitize an untrusted value before printing it with a trusted style.
Sourcepub fn print_table(&self, table: &Table, plain_fallback: &str)
pub fn print_table(&self, table: &Table, plain_fallback: &str)
Print a table with a trusted plain fallback.
Use Self::print_table_untrusted when the fallback is untrusted.
Sourcepub fn print_table_untrusted(&self, table: &Table, plain_fallback: &str)
pub fn print_table_untrusted(&self, table: &Table, plain_fallback: &str)
Print a table with a sanitized untrusted plain fallback.
Sourcepub fn print_panel(&self, panel: &Panel<'_>, plain_fallback: &str)
pub fn print_panel(&self, panel: &Panel<'_>, plain_fallback: &str)
Print a panel with a trusted plain fallback.
Use Self::print_panel_untrusted when the fallback is untrusted.
Sourcepub fn print_panel_untrusted(&self, panel: &Panel<'_>, plain_fallback: &str)
pub fn print_panel_untrusted(&self, panel: &Panel<'_>, plain_fallback: &str)
Print a panel with a sanitized untrusted plain fallback.