pub struct SerializedCustomMessage { /* private fields */ }Expand description
A lightweight CustomMessage stand-in that holds pre-serialized data.
Useful for ferrying custom messages across spawn_blocking boundaries or
other contexts where the original Box<dyn CustomMessage> (which is
neither Clone nor necessarily transferable) must be replaced with a
plain-data snapshot.
Implements CustomMessage so it can be stored in AgentMessage::Custom
and round-trips faithfully through serialize_custom_message /
deserialize_custom_message.
Implementations§
Source§impl SerializedCustomMessage
impl SerializedCustomMessage
Sourcepub fn new(name: impl Into<String>, json: Value) -> Self
pub fn new(name: impl Into<String>, json: Value) -> Self
Create a new serialized custom message from a name and JSON payload.
Sourcepub fn from_custom(msg: &dyn CustomMessage) -> Option<Self>
pub fn from_custom(msg: &dyn CustomMessage) -> Option<Self>
Attempt to create a SerializedCustomMessage from a dyn CustomMessage.
Returns None if the custom message does not support serialization.
Trait Implementations§
Source§impl Clone for SerializedCustomMessage
impl Clone for SerializedCustomMessage
Source§fn clone(&self) -> SerializedCustomMessage
fn clone(&self) -> SerializedCustomMessage
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 SerializedCustomMessage
impl RefUnwindSafe for SerializedCustomMessage
impl Send for SerializedCustomMessage
impl Sync for SerializedCustomMessage
impl Unpin for SerializedCustomMessage
impl UnsafeUnpin for SerializedCustomMessage
impl UnwindSafe for SerializedCustomMessage
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