Struct OwnedMessage
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§
§impl OwnedMessage
impl OwnedMessage
pub fn serialize(self) -> SerializedMessage<Resource>
pub fn serialize(self) -> SerializedMessage<Resource>
Serializes the message and returns it.
§impl OwnedMessage
impl OwnedMessage
pub fn new<T>(data: T) -> OwnedMessagewhere
T: SerializeMessage + Send,
pub fn new<T>(data: T) -> OwnedMessagewhere
T: SerializeMessage + Send,
Creates a new message wrapping data
, which will be lazily serialized
when needed.
pub fn serialized(s: SerializedMessage<Resource>) -> OwnedMessage
pub fn serialized(s: SerializedMessage<Resource>) -> OwnedMessage
Creates a new message from already-serialized data in s
.
pub fn parse<T>(self) -> Result<T, Error>where
T: 'static + DefaultEncoding,
<T as DefaultEncoding>::Encoding: for<'a> MessageDecode<'a, T, Resource>,
pub fn parse<T>(self) -> Result<T, Error>where
T: 'static + DefaultEncoding,
<T as DefaultEncoding>::Encoding: for<'a> MessageDecode<'a, T, Resource>,
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.
pub fn try_unwrap<T>(self) -> Result<T, OwnedMessage>where
T: 'static,
pub fn try_unwrap<T>(self) -> Result<T, OwnedMessage>where
T: 'static,
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§
§impl Debug for OwnedMessage
impl Debug for OwnedMessage
§impl Default for OwnedMessage
impl Default for OwnedMessage
§fn default() -> OwnedMessage
fn default() -> OwnedMessage
Returns the “default value” for a type. Read more
§impl DefaultEncoding for OwnedMessage
impl DefaultEncoding for OwnedMessage
§type Encoding = MessageEncoding<MessageEncoder>
type Encoding = MessageEncoding<MessageEncoder>
The encoding to use for the serialization. Read more
§impl From<OwnedMessage> for Message<'_>
impl From<OwnedMessage> for Message<'_>
§fn from(m: OwnedMessage) -> Message<'_>
fn from(m: OwnedMessage) -> Message<'_>
Converts to this type from the input type.
§impl MessageDecode<'_, OwnedMessage, Resource> for MessageEncoder
impl MessageDecode<'_, OwnedMessage, Resource> for MessageEncoder
§fn read_message(
item: &mut InplaceOption<'_, OwnedMessage>,
reader: MessageReader<'_, '_, Resource>,
) -> Result<(), Error>
fn read_message( item: &mut InplaceOption<'_, OwnedMessage>, reader: MessageReader<'_, '_, Resource>, ) -> Result<(), Error>
Reads a message into
item
.§impl MessageEncode<OwnedMessage, Resource> for MessageEncoder
impl MessageEncode<OwnedMessage, Resource> for MessageEncoder
§fn write_message(item: OwnedMessage, writer: MessageWriter<'_, '_, Resource>)
fn write_message(item: OwnedMessage, writer: MessageWriter<'_, '_, Resource>)
Writes
item
as a message.§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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§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
§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
§impl<T> SerializeMessage for Twhere
T: 'static + MeshPayload + Send,
impl<T> SerializeMessage for Twhere
T: 'static + MeshPayload + Send,
§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
.§fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
Writes the message, as in
MessageEncode::write_message
.§fn extract(self) -> <T as SerializeMessage>::Concrete
fn extract(self) -> <T as SerializeMessage>::Concrete
Extract the concrete message.