pub struct OwnedMessage(/* private fields */);
Expand description
A message on a port.
The message has a static lifetime and is Send
, so it is appropriate for
storing and using across threads.
See Message
for a version that can reference data with non-static
lifetime.
Implementations§
Source§impl OwnedMessage
impl OwnedMessage
Sourcepub fn serialize(self) -> SerializedMessage
pub fn serialize(self) -> SerializedMessage
Serializes the message and returns it.
Source§impl OwnedMessage
impl OwnedMessage
Sourcepub fn new<T: SerializeMessage + Send>(data: T) -> Self
pub fn new<T: SerializeMessage + Send>(data: T) -> Self
Creates a new message wrapping data
, which will be lazily serialized
when needed.
Sourcepub fn serialized(s: SerializedMessage) -> Self
pub fn serialized(s: SerializedMessage) -> Self
Creates a new message from already-serialized data in s
.
Sourcepub fn parse<T>(self) -> Result<T, Error>
pub fn parse<T>(self) -> Result<T, Error>
Parses the message into a value of type T
.
If the message was constructed with new<T>
, then the round trip
serialization/deserialization is skipped.
Sourcepub fn try_unwrap<T: 'static>(self) -> Result<T, Self>
pub fn try_unwrap<T: 'static>(self) -> Result<T, Self>
Tries to unwrap the message into a value of type T
.
If the message was not created with OwnedMessage::new<T>
, then this
returns Err(self)
.
Trait Implementations§
Source§impl Debug for OwnedMessage
impl Debug for OwnedMessage
Source§impl Default for OwnedMessage
impl Default for OwnedMessage
Source§fn default() -> OwnedMessage
fn default() -> OwnedMessage
Returns the “default value” for a type. Read more
Source§impl DefaultEncoding for OwnedMessage
impl DefaultEncoding for OwnedMessage
Source§type Encoding = MessageEncoding<MessageEncoder>
type Encoding = MessageEncoding<MessageEncoder>
The encoding to use for the serialization. Read more
Source§impl From<OwnedMessage> for Message<'_>
impl From<OwnedMessage> for Message<'_>
Source§fn from(m: OwnedMessage) -> Self
fn from(m: OwnedMessage) -> Self
Converts to this type from the input type.
Source§impl MessageDecode<'_, OwnedMessage, Resource> for MessageEncoder
impl MessageDecode<'_, OwnedMessage, Resource> for MessageEncoder
Source§fn read_message(
item: &mut InplaceOption<'_, OwnedMessage>,
reader: MessageReader<'_, '_, Resource>,
) -> Result<()>
fn read_message( item: &mut InplaceOption<'_, OwnedMessage>, reader: MessageReader<'_, '_, Resource>, ) -> Result<()>
Reads a message into
item
.Source§impl MessageEncode<OwnedMessage, Resource> for MessageEncoder
impl MessageEncode<OwnedMessage, Resource> for MessageEncoder
Source§fn write_message(item: OwnedMessage, writer: MessageWriter<'_, '_, Resource>)
fn write_message(item: OwnedMessage, writer: MessageWriter<'_, '_, Resource>)
Writes
item
as a message.Source§fn compute_message_size(item: &mut OwnedMessage, sizer: MessageSizer<'_>)
fn compute_message_size(item: &mut OwnedMessage, sizer: MessageSizer<'_>)
Computes the size of
item
as a message. Read moreAuto Trait Implementations§
impl Freeze for OwnedMessage
impl !RefUnwindSafe for OwnedMessage
impl Send for OwnedMessage
impl !Sync for OwnedMessage
impl Unpin for OwnedMessage
impl !UnwindSafe for OwnedMessage
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> MeshField for Twhere
T: DefaultEncoding,
<T as DefaultEncoding>::Encoding: FieldEncode<T, Resource> + for<'a> FieldDecode<'a, T, Resource> + Send + Sync,
impl<T> MeshField for Twhere
T: DefaultEncoding,
<T as DefaultEncoding>::Encoding: FieldEncode<T, Resource> + for<'a> FieldDecode<'a, T, Resource> + Send + Sync,
type Encoding = <T as DefaultEncoding>::Encoding
Source§impl<T> MeshPayload for Twhere
T: DefaultEncoding + Any + Send + 'static,
<T as DefaultEncoding>::Encoding: MessageEncode<T, Resource> + for<'a> MessageDecode<'a, T, Resource> + FieldEncode<T, Resource> + for<'a> FieldDecode<'a, T, Resource> + Send + Sync,
impl<T> MeshPayload for Twhere
T: DefaultEncoding + Any + Send + 'static,
<T as DefaultEncoding>::Encoding: MessageEncode<T, Resource> + for<'a> MessageDecode<'a, T, Resource> + FieldEncode<T, Resource> + for<'a> FieldDecode<'a, T, Resource> + Send + Sync,
type Encoding = <T as DefaultEncoding>::Encoding
Source§impl<T> SerializeMessage for Twhere
T: 'static + MeshPayload + Send,
impl<T> SerializeMessage for Twhere
T: 'static + MeshPayload + Send,
Source§fn compute_message_size(&mut self, sizer: MessageSizer<'_>)
fn compute_message_size(&mut self, sizer: MessageSizer<'_>)
Computes the message size, as in
MessageEncode::compute_message_size
.Source§fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
Writes the message, as in
MessageEncode::write_message
.Source§fn extract(self) -> <T as SerializeMessage>::Concrete
fn extract(self) -> <T as SerializeMessage>::Concrete
Extract the concrete message.