pub struct Envelope {
pub data: Option<Value>,
pub metadata: Option<Metadata>,
pub error: Option<ErrorEnvelope>,
pub warnings: Vec<String>,
/* private fields */
}Expand description
Top-level output envelope rendered for successful and failed commands.
Fields§
§data: Option<Value>Successful command data.
metadata: Option<Metadata>Optional execution metadata, controlled by --verbose.
error: Option<ErrorEnvelope>Structured error information for failed commands.
warnings: Vec<String>Non-fatal warnings.
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_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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Envelope
impl<'de> Deserialize<'de> for Envelope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Envelope
Auto Trait Implementations§
impl Freeze for Envelope
impl RefUnwindSafe for Envelope
impl Send for Envelope
impl Sync for Envelope
impl Unpin for Envelope
impl UnsafeUnpin for Envelope
impl UnwindSafe for Envelope
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