pub enum MessagePtr {
Shared(Arc<dyn Message>),
Static(&'static dyn Message),
}Expand description
Reference-counted wrapper around a Message.
Provides type-safe downcasting to recover the concrete message type. For zero-sized messages, avoids heap allocation entirely.
Variants§
Implementations§
Source§impl MessagePtr
impl MessagePtr
Sourcepub fn new<T: Message + 'static>(msg: T) -> Self
pub fn new<T: Message + 'static>(msg: T) -> Self
Creates a new MessagePtr. For zero-sized types this avoids heap allocation
by using a static reference — ZSTs have no data, only the vtable pointer matters.
Sourcepub fn try_as_type<T: 'static>(&self) -> Option<&T>
pub fn try_as_type<T: 'static>(&self) -> Option<&T>
Attempts to downcast to T. Returns None if the type does not match.
Sourcepub fn virtual_size(&self) -> usize
pub fn virtual_size(&self) -> usize
Returns the virtual size of the message for bandwidth simulation.
Trait Implementations§
Source§impl Clone for MessagePtr
impl Clone for MessagePtr
Source§fn clone(&self) -> MessagePtr
fn clone(&self) -> MessagePtr
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 moreAuto Trait Implementations§
impl Freeze for MessagePtr
impl !RefUnwindSafe for MessagePtr
impl Send for MessagePtr
impl Sync for MessagePtr
impl Unpin for MessagePtr
impl UnsafeUnpin for MessagePtr
impl !UnwindSafe for MessagePtr
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