pub struct Envelope {
pub data: Option<Value>,
pub pagination: Option<PaginationMeta>,
pub metadata: Option<Metadata>,
pub error: Option<ErrorEnvelope>,
pub warnings: Vec<String>,
pub next_actions: Vec<NextAction>,
pub fix: Option<String>,
/* private fields */
}Expand description
Top-level output envelope rendered for successful and failed commands.
Fields§
§data: Option<Value>Successful command data.
pagination: Option<PaginationMeta>Client-side pagination facts, present whenever pagination was
actually applied — an effective --limit or --offset greater than
zero, not merely a command that opted into
with_pagination — regardless
of --verbose. A default_limit of 0 (“unlimited”) with neither
flag passed leaves this None even for a paginating command. Unlike
metadata, this is not debugging output; a
caller relies on it to know whether more data exists at all.
metadata: Option<Metadata>Optional execution metadata, controlled by --verbose.
error: Option<ErrorEnvelope>Structured error information for failed commands.
warnings: Vec<String>Non-fatal warnings.
next_actions: Vec<NextAction>Suggested follow-up actions for the caller (agent or human).
fix: Option<String>Optional recovery guidance for failed commands.
Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn success(data: impl Serialize, system: impl Into<String>) -> Self
pub fn success(data: impl Serialize, system: impl Into<String>) -> Self
Creates a success envelope from serializable data.
Sourcepub fn error(
code: impl Into<String>,
message: impl Into<String>,
system: impl Into<String>,
) -> Self
pub fn error( code: impl Into<String>, message: impl Into<String>, system: impl Into<String>, ) -> Self
Creates a generic error envelope.
Sourcepub fn error_detail(
code: impl Into<String>,
message: impl Into<String>,
system: impl Into<String>,
request_id: impl Into<String>,
) -> Self
pub fn error_detail( code: impl Into<String>, message: impl Into<String>, system: impl Into<String>, request_id: impl Into<String>, ) -> Self
Creates a structured error envelope with request id.
Sourcepub fn with_next_actions(self, actions: Vec<NextAction>) -> Self
pub fn with_next_actions(self, actions: Vec<NextAction>) -> Self
Attaches suggested follow-up actions.
Sourcepub fn with_fix(self, fix: impl Into<String>) -> Self
pub fn with_fix(self, fix: impl Into<String>) -> Self
Attaches recovery guidance for a failed command (no-op on success envelopes).
Sourcepub fn with_dry_run(self) -> Self
pub fn with_dry_run(self) -> Self
Marks the envelope as a dry-run response.
Sourcepub fn with_context(
&mut self,
command: &str,
env: &str,
identity: &str,
duration: Duration,
user_args: Option<Value>,
effective_args: Option<Value>,
)
pub fn with_context( &mut self, command: &str, env: &str, identity: &str, duration: Duration, user_args: Option<Value>, effective_args: Option<Value>, )
Adds command execution context to envelope metadata.
Sourcepub fn prepare_for_render(&self, verbose: &str) -> Self
pub fn prepare_for_render(&self, verbose: &str) -> Self
Returns a copy with metadata stripped or filtered according to --verbose.
Sourcepub fn add_warning(&mut self, message: impl Into<String>)
pub fn add_warning(&mut self, message: impl Into<String>)
Appends a non-fatal warning.