pub struct Output { /* private fields */ }Expand description
Result type that handles output formatting and exit codes.
Builds Agent-First Data-compliant JSON (code/result/trace/error), redacts secrets, formats via agent_first_data, and prints protocol/log events to stdout.
Implementations§
Source§impl Output
impl Output
pub fn new(format: OutputFormat) -> Self
Sourcepub fn value(&self, value: Value) -> ExitCode
pub fn value(&self, value: Value) -> ExitCode
Emit a pre-built AFDATA value whose top-level code is already set.
Sourcepub fn ok_trace<T: Serialize>(
&self,
result: T,
trace: impl Serialize,
) -> ExitCode
pub fn ok_trace<T: Serialize>( &self, result: T, trace: impl Serialize, ) -> ExitCode
{code: “ok”, result: …, trace: …} → stdout
Sourcepub fn error(&self, error_code: &str, message: &str) -> ExitCode
pub fn error(&self, error_code: &str, message: &str) -> ExitCode
{code: “<error_code>”, error: “msg”, hint: “…”, trace: {duration_ms: 0}} → stdout
Sourcepub fn error_hint(
&self,
error_code: &str,
message: &str,
hint: Option<&str>,
) -> ExitCode
pub fn error_hint( &self, error_code: &str, message: &str, hint: Option<&str>, ) -> ExitCode
Like [error] but with an actionable hint for remediation.
Sourcepub fn error_from(&self, error_code: &str, err: &Error) -> ExitCode
pub fn error_from(&self, error_code: &str, err: &Error) -> ExitCode
Output error from anyhow::Error
Sourcepub fn error_hypha(&self, err: &HyphaError) -> ExitCode
pub fn error_hypha(&self, err: &HyphaError) -> ExitCode
Output error from crate::HyphaError (includes hint when present).
Sourcepub fn progress(&self, step: u32, total: u32, message: &str, data: Value)
pub fn progress(&self, step: u32, total: u32, message: &str, data: Value)
Agent-First Data progress step → stdout {“code”: “progress”, “current”: N, “total”: M, “message”: “…”, …}
Sourcepub fn download_progress(&self, downloaded_bytes: u64, total_bytes: Option<u64>)
pub fn download_progress(&self, downloaded_bytes: u64, total_bytes: Option<u64>)
Byte-level download progress → stdout {“code”: “download_progress”, “downloaded_bytes”: N, “total_bytes”: M}