Skip to main content

format

Function format 

Source
pub fn format<T: Serialize>(data: &T) -> Result<String>
Expand description

Format data as plain text.

Uses JSON representation but without colors or fancy formatting. Suitable for piping to other commands or scripts.

§Errors

Returns an error if JSON serialization fails (propagated from the underlying json::format_compact call).

§Examples

use serde::Serialize;
use mcp_execution_cli::formatters::text;

#[derive(Serialize)]
struct Data { value: i32 }

let data = Data { value: 42 };
let text = text::format(&data).unwrap();
assert!(text.contains("42"));