pub struct SharedMessage<T> { /* private fields */ }Expand description
A shared message wrapper for zero-copy message sharing.
This type wraps Arc<Message<T>> to enable zero-copy sharing of messages
in fan-out scenarios where one message needs to be sent to multiple consumers.
§Example
use streamweave_message::{Message, MessageId, SharedMessage};
let msg = Message::new(42, MessageId::new_uuid());
let shared = SharedMessage::from(msg);
let cloned = shared.clone(); // Zero-cost clone of ArcImplementations§
Sourcepub fn try_unwrap(self) -> Result<Message<T>, Self>
pub fn try_unwrap(self) -> Result<Message<T>, Self>
Try to unwrap the Arc, returning the owned Message if this is the only reference.
Returns Ok(Message<T>) if this is the only reference, Err(SharedMessage<T>) otherwise.
Sourcepub fn metadata(&self) -> &MessageMetadata
pub fn metadata(&self) -> &MessageMetadata
Get the metadata.
Trait Implementations§
Source§fn clone(&self) -> SharedMessage<T>
fn clone(&self) -> SharedMessage<T>
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§fn from(shared: SharedMessage<T>) -> Self
fn from(shared: SharedMessage<T>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
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