Skip to main content

EventEnvelope

Struct EventEnvelope 

Source
pub struct EventEnvelope { /* private fields */ }
Expand description

The immutable message container between functions. Build with the fluent setters (EventEnvelope::new().set_to("v1.echo").set_body(...)). Wire format (increment 59): the standard event envelope wire format — one MsgPack map with these descriptive string keys, shared verbatim with the Java engine for Event over HTTP (normative spec: docs/guides/event-envelope-wire-format.md in the Java repo; golden vectors under tests/resources/envelope-vectors/). Encoders emit id and headers always and other fields only when set; decoders treat absent and nil identically and ignore unknown keys (Java may add tags, stack, obj_type, exception).

Implementations§

Source§

impl EventEnvelope

Source

pub fn new() -> Self

Source

pub fn set_to(self, route: &str) -> Self

Source

pub fn set_from(self, route: &str) -> Self

Source

pub fn set_reply_to(self, route: &str) -> Self

Source

pub fn clear_reply_to(self) -> Self

Remove the reply-to address (Java setReplyTo(null)) — used when an event is re-targeted, e.g. the declarative Event-over-HTTP forward nulls the local callback route before the envelope crosses the wire.

Source

pub fn clear_to(self) -> Self

Remove the routing address (Java setTo(null)) — used when an envelope is serialized for a wire that rewrites addressing on the consuming side, e.g. the envelope-mode streaming frames, so a server-internal route name never leaks.

Source

pub fn set_correlation_id(self, cid: &str) -> Self

Source

pub fn set_trace(self, trace_id: &str, trace_path: &str) -> Self

Source

pub fn set_span_id(self, span_id: &str) -> Self

Carry a span id on the envelope — the sender’s span, which the receiver adopts as its parent_span_id (OTel lineage).

Source

pub fn set_status(self, status: i32) -> Self

Source

pub fn set_header(self, key: &str, value: &str) -> Self

Source

pub fn set_body<T: Serialize>(self, value: T) -> Result<Self, AppError>

Serialize any Serialize value into the dynamic body (the analog of Java’s setBody(Object)).

Source

pub fn set_raw_body(self, value: Value) -> Self

Set the body from an already-dynamic value.

Source

pub fn id(&self) -> &str

Source

pub fn to(&self) -> Option<&str>

Source

pub fn from(&self) -> Option<&str>

Source

pub fn reply_to(&self) -> Option<&str>

Source

pub fn correlation_id(&self) -> Option<&str>

Source

pub fn trace_id(&self) -> Option<&str>

Source

pub fn trace_path(&self) -> Option<&str>

Source

pub fn span_id(&self) -> Option<&str>

The sender’s span id (the receiver’s parent span).

Source

pub fn status(&self) -> i32

HTTP-style status; unset means 200 (Java getStatus).

Source

pub fn has_error(&self) -> bool

An error condition is a status code >= 400 (Java hasError).

Source

pub fn headers(&self) -> &HashMap<String, String>

Source

pub fn header(&self, key: &str) -> Option<&str>

Source

pub fn body(&self) -> &Value

Source

pub fn body_as<T: DeserializeOwned>(&self) -> Result<T, AppError>

Deserialize the dynamic body into a concrete type (the analog of Java’s getBody(Class)).

Source

pub fn exec_time(&self) -> Option<f32>

Function execution time in milliseconds, when stamped by a worker.

Source

pub fn round_trip(&self) -> Option<f32>

RPC round-trip milliseconds (Java getRoundTrip), when measured.

Source

pub fn set_round_trip(self, ms: f32) -> Self

Stamp the RPC round-trip time (Java parity: the requester measures the full request/response cycle).

Source

pub fn annotations(&self) -> &HashMap<String, Value>

Trace annotations riding this (reply) envelope (Java getAnnotations).

Source

pub fn clear_annotations(self) -> Self

Remove all annotations (Java clearAnnotations) — the RPC caller strips them after folding them into the trace record.

Source

pub fn tag(&self, key: &str) -> Option<&str>

An engine-managed tag value (Java getTag).

Source

pub fn add_tag(self, key: &str, value: &str) -> Self

Attach an engine-managed tag (Java addTag). Reserved for the engine: tags never reach a user function’s view — the worker scrubs them at delivery after extracting what it injects into the header copy.

Source

pub fn to_bytes(&self) -> Result<Vec<u8>, AppError>

Encode the envelope as MsgPack bytes (idiomatic serde — design D4).

The body’s Nil map entries are omitted unless serializer.null.transport is true — the Rust mirror of Java MsgPack.packMap’s null-skip. Since increment 58 (the F2 decision) the same strip also runs explicitly on the in-memory fast path (platform::normalize_null_transport), so delivery semantics are deterministic on every hop — here it is normally a no-op. The clone + strip runs only when the body actually carries a strippable Nil (has_nil_map_entry); otherwise — a scalar body, a structured body with no nulls, or transport on — self encodes directly with no extra allocation, so the common case pays only a read-only scan.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, AppError>

Decode an envelope from MsgPack bytes.

Trait Implementations§

Source§

impl Clone for EventEnvelope

Source§

fn clone(&self) -> EventEnvelope

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EventEnvelope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EventEnvelope

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for EventEnvelope

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for EventEnvelope

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V