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 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}
Auto Trait Implementations§
impl Freeze for Output
impl RefUnwindSafe for Output
impl Send for Output
impl Sync for Output
impl Unpin for Output
impl UnsafeUnpin for Output
impl UnwindSafe for Output
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more