pub struct Envelope {
pub api_version: &'static str,
pub kind: String,
pub host: String,
pub status: Status,
pub data: Option<Value>,
pub error: Option<ApiError>,
pub hints: Option<Value>,
}Expand description
The machine-readable response wrapper for every command.
Fields§
§api_version: &'static strSchema version, always API_VERSION.
kind: StringThe payload kind (e.g. ServiceList, Error).
host: StringHost the response pertains to.
status: StatusWhether the operation succeeded.
data: Option<Value>Success payload, present when status is ok.
error: Option<ApiError>Error payload, present when status is error.
hints: Option<Value>Optional machine-actionable hints (e.g. a reverse command).
Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn error(kind: &str, host: &str, err: ApiError) -> Self
pub fn error(kind: &str, host: &str, err: ApiError) -> Self
Build an error envelope carrying err.
Sourcepub fn with_hints(self, hints: Value) -> Self
pub fn with_hints(self, hints: Value) -> Self
Attach machine-actionable hints (e.g. the reversibility hint, Section 8).
Sourcepub fn to_json_string(&self) -> String
pub fn to_json_string(&self) -> String
Serialize the envelope to a pretty-printed JSON string.
Returns a valid fez/v1 error envelope on serialization failure so that
callers always receive syntactically correct JSON.
Trait Implementations§
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