pub struct ResponseEnvelope {
pub status: ResponseStatus,
pub payload: Option<Value>,
pub error_code: Option<u32>,
pub error_message: Option<String>,
pub request_id: Option<u64>,
}Expand description
Response envelope wrapping a response for FFI transport
Fields§
§status: ResponseStatusResponse status
payload: Option<Value>Serialized response payload (on success) or null
error_code: Option<u32>Error code (on failure)
error_message: Option<String>Error message (on failure)
request_id: Option<u64>Original request ID for correlation
Implementations§
Source§impl ResponseEnvelope
impl ResponseEnvelope
Sourcepub fn success_typed<T: Serialize>(value: &T) -> Result<Self, Error>
pub fn success_typed<T: Serialize>(value: &T) -> Result<Self, Error>
Create a success response from a serializable value
Sourcepub fn success_raw(data: &[u8]) -> Result<Self, Error>
pub fn success_raw(data: &[u8]) -> Result<Self, Error>
Create a success response from raw bytes (already JSON-encoded)
Sourcepub fn from_error(err: &PluginError) -> Self
pub fn from_error(err: &PluginError) -> Self
Create an error response from a PluginError
Sourcepub fn with_request_id(self, id: u64) -> Self
pub fn with_request_id(self, id: u64) -> Self
Set request ID for correlation
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if this is a success response
Sourcepub fn payload_as<T: DeserializeOwned>(&self) -> Result<Option<T>, Error>
pub fn payload_as<T: DeserializeOwned>(&self) -> Result<Option<T>, Error>
Get the payload if success
This method deserializes directly from the JSON value without cloning.
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self, Error>
pub fn from_bytes(data: &[u8]) -> Result<Self, Error>
Deserialize from bytes
Trait Implementations§
Source§impl Clone for ResponseEnvelope
impl Clone for ResponseEnvelope
Source§fn clone(&self) -> ResponseEnvelope
fn clone(&self) -> ResponseEnvelope
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ResponseEnvelope
impl Debug for ResponseEnvelope
Source§impl Default for ResponseEnvelope
impl Default for ResponseEnvelope
Source§impl<'de> Deserialize<'de> for ResponseEnvelope
impl<'de> Deserialize<'de> for ResponseEnvelope
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
Auto Trait Implementations§
impl Freeze for ResponseEnvelope
impl RefUnwindSafe for ResponseEnvelope
impl Send for ResponseEnvelope
impl Sync for ResponseEnvelope
impl Unpin for ResponseEnvelope
impl UnsafeUnpin for ResponseEnvelope
impl UnwindSafe for ResponseEnvelope
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