pub struct Envelope {
pub value: Arc<dyn Any + Send + Sync>,
/* private fields */
}Expand description
A type-erased envelope that can carry any Send + Sync value.
Fields§
§value: Arc<dyn Any + Send + Sync>Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn new<T: 'static + Send + Sync>(
value: T,
msg_id: u64,
tracker: Option<Arc<CompletionTracker>>,
) -> Self
pub fn new<T: 'static + Send + Sync>( value: T, msg_id: u64, tracker: Option<Arc<CompletionTracker>>, ) -> Self
Create a new envelope from any Send + Sync value.
Sourcepub fn with_origin<T: 'static + Send + Sync>(
value: T,
msg_id: u64,
tracker: Option<Arc<CompletionTracker>>,
origin: u64,
) -> Self
pub fn with_origin<T: 'static + Send + Sync>( value: T, msg_id: u64, tracker: Option<Arc<CompletionTracker>>, origin: u64, ) -> Self
Create a new envelope with a specific origin stream ID.
Sourcepub fn from_any(
value: Arc<dyn Any + Send + Sync>,
type_id: TypeId,
msg_id: u64,
tracker: Option<Arc<CompletionTracker>>,
) -> Self
pub fn from_any( value: Arc<dyn Any + Send + Sync>, type_id: TypeId, msg_id: u64, tracker: Option<Arc<CompletionTracker>>, ) -> Self
Create an envelope from an already type-erased value with known TypeId.
This is useful when you have a value that’s already been type-erased (e.g., from a registry or dynamic dispatch) but want to preserve its original type for downstream filtering.
Sourcepub fn from_any_with_origin(
value: Arc<dyn Any + Send + Sync>,
type_id: TypeId,
msg_id: u64,
tracker: Option<Arc<CompletionTracker>>,
origin: u64,
) -> Self
pub fn from_any_with_origin( value: Arc<dyn Any + Send + Sync>, type_id: TypeId, msg_id: u64, tracker: Option<Arc<CompletionTracker>>, origin: u64, ) -> Self
Create an envelope from type-erased value with a specific origin.
Sourcepub fn tracker(&self) -> Option<Arc<CompletionTracker>>
pub fn tracker(&self) -> Option<Arc<CompletionTracker>>
Get the completion tracker if present.
Sourcepub fn with_new_origin(&self, origin: u64) -> Self
pub fn with_new_origin(&self, origin: u64) -> Self
Create a copy of this envelope with a new origin.
Sourcepub fn without_tracker(&self) -> Self
pub fn without_tracker(&self) -> Self
Create a copy of this envelope without a tracker. Used when forwarding events - the target stream has its own handlers.
Sourcepub fn downcast_ref<T: 'static>(&self) -> Option<&T>
pub fn downcast_ref<T: 'static>(&self) -> Option<&T>
Attempt to downcast to a concrete type reference.
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 !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