Struct Message
pub struct Message<'a>(/* private fields */);Expand description
A message on a port.
The message may reference data with non-static lifetime, and it may not be
Send. See OwnedMessage for a version that is Send.
Implementations§
§impl<'a> Message<'a>
 
impl<'a> Message<'a>
pub fn new<T>(message: T) -> Message<'a>where
    T: SerializeMessage + Send,
pub fn new<T>(message: T) -> Message<'a>where
    T: SerializeMessage + Send,
Returns a new instance wrapping message. The message will be boxed and
will be lazily serialized when needed.
pub fn serialized(data: &'a [u8], resources: Vec<Resource>) -> Message<'a>
pub fn serialized(data: &'a [u8], resources: Vec<Resource>) -> Message<'a>
Returns an instance for a serialized message with data and
resources.
pub fn into_owned(self) -> OwnedMessage
pub fn into_owned(self) -> OwnedMessage
Converts the message into an OwnedMessage.
If the message was created with Message::new or
From<OwnedMessage>, then this operation is cheap. Otherwise, this
operation will serialize the message and allocate a new buffer.
pub fn serialize(self) -> (Cow<'a, [u8]>, Vec<Resource>)
pub fn serialize(self) -> (Cow<'a, [u8]>, Vec<Resource>)
Serializes the message and returns it.
If the message is already serialized, then this is a cheap operation.
pub fn parse<T>(self) -> Result<T, Error>where
    T: 'static + DefaultEncoding,
    <T as DefaultEncoding>::Encoding: for<'b> MessageDecode<'b, T, Resource>,
pub fn parse<T>(self) -> Result<T, Error>where
    T: 'static + DefaultEncoding,
    <T as DefaultEncoding>::Encoding: for<'b> MessageDecode<'b, 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 parse_non_static<T>(self) -> Result<T, Error>
pub fn parse_non_static<T>(self) -> Result<T, Error>
Parses the message into a value of type T.
When T has static lifetime, prefer Message::parse instead, since
it can recover a T passed to Message::new without round-trip
serialization.
Trait Implementations§
§impl DefaultEncoding for Message<'_>
 
impl DefaultEncoding for Message<'_>
§type Encoding = MessageEncoding<MessageEncoder>
 
type Encoding = MessageEncoding<MessageEncoder>
§impl From<OwnedMessage> for Message<'_>
 
impl From<OwnedMessage> for Message<'_>
§fn from(m: OwnedMessage) -> Message<'_>
 
fn from(m: OwnedMessage) -> Message<'_>
§impl MessageEncode<Message<'_>, Resource> for MessageEncoder
 
impl MessageEncode<Message<'_>, Resource> for MessageEncoder
§fn write_message(item: Message<'_>, writer: MessageWriter<'_, '_, Resource>)
 
fn write_message(item: Message<'_>, writer: MessageWriter<'_, '_, Resource>)
item as a message.§fn compute_message_size(item: &mut Message<'_>, sizer: MessageSizer<'_>)
 
fn compute_message_size(item: &mut Message<'_>, sizer: MessageSizer<'_>)
item as a message. Read more