pub struct RequestEnvelope {
pub type_tag: String,
pub payload: Value,
pub request_id: Option<u64>,
pub correlation_id: Option<String>,
}Expand description
Request envelope wrapping a message for FFI transport
The type_tag identifies the handler, and payload contains the serialized request data.
Fields§
§type_tag: StringMessage type identifier (e.g., “user.create”, “order.submit”)
payload: ValueSerialized request payload (JSON)
request_id: Option<u64>Optional request ID for correlation
correlation_id: Option<String>Optional correlation ID for distributed tracing
Implementations§
Source§impl RequestEnvelope
impl RequestEnvelope
Sourcepub fn new(type_tag: impl Into<String>, payload: Value) -> RequestEnvelope
pub fn new(type_tag: impl Into<String>, payload: Value) -> RequestEnvelope
Create a new request envelope
Sourcepub fn with_request_id(self, id: u64) -> RequestEnvelope
pub fn with_request_id(self, id: u64) -> RequestEnvelope
Set request ID
Sourcepub fn with_correlation_id(self, id: impl Into<String>) -> RequestEnvelope
pub fn with_correlation_id(self, id: impl Into<String>) -> RequestEnvelope
Set correlation ID
Sourcepub fn from_typed<T>(
type_tag: impl Into<String>,
payload: &T,
) -> Result<RequestEnvelope, Error>where
T: Serialize,
pub fn from_typed<T>(
type_tag: impl Into<String>,
payload: &T,
) -> Result<RequestEnvelope, Error>where
T: Serialize,
Create from type tag and serializable payload
Sourcepub fn payload_as<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
pub fn payload_as<T>(&self) -> Result<T, Error>where
T: DeserializeOwned,
Deserialize the payload to a typed value
This method deserializes directly from the JSON value without cloning.
Sourcepub fn from_bytes(data: &[u8]) -> Result<RequestEnvelope, Error>
pub fn from_bytes(data: &[u8]) -> Result<RequestEnvelope, Error>
Deserialize from bytes
Trait Implementations§
Source§impl Clone for RequestEnvelope
impl Clone for RequestEnvelope
Source§fn clone(&self) -> RequestEnvelope
fn clone(&self) -> RequestEnvelope
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 RequestEnvelope
impl Debug for RequestEnvelope
Source§impl<'de> Deserialize<'de> for RequestEnvelope
impl<'de> Deserialize<'de> for RequestEnvelope
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<RequestEnvelope, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<RequestEnvelope, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for RequestEnvelope
impl Serialize for RequestEnvelope
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for RequestEnvelope
impl RefUnwindSafe for RequestEnvelope
impl Send for RequestEnvelope
impl Sync for RequestEnvelope
impl Unpin for RequestEnvelope
impl UnsafeUnpin for RequestEnvelope
impl UnwindSafe for RequestEnvelope
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