Skip to content

Struct envelope::ResponseEnvelope

zaun_community_protocol::envelope::ResponseEnvelope · Struct

pub struct ResponseEnvelope { … }

{ "v", "type": "response", "request_id", "ok", "body" | "error" }.

request_id is null when the command’s id could not be read.

Envelope version.

The command’s request_id, or None (null).

Success body or error.

pub fn ok(request_id: RequestId, body: Box<RawValue>) -> Self

A success response at PROTOCOL_VERSION.

pub fn ok_json<T>(request_id: RequestId, body: &T) -> Result<Self>

A success response whose body is serialised from body.

body fails to serialise as JSON.

pub fn error(request_id: Option<RequestId>, error: ErrorBody) -> Self

An error response at PROTOCOL_VERSION.

pub fn error_body(&self) -> Option<&ErrorBody>

The error, if this is a failure.

pub fn is_recorded(&self) -> bool

Whether this response is stored as the idempotency record: every success and every error except BUSY, RATE_LIMITED, INTERNAL and SLOWMODE_ACTIVE.

Clone, Debug, Deserialize<'de>, Serialize

Full rustdoc page