Skip to main content

MessageRead

Trait MessageRead 

Source
pub trait MessageRead {
    // Required methods
    fn msg_code(&self) -> MsgCode;
    fn msg_type(&self) -> MsgType;
    fn msg_id(&self) -> MsgId;
    fn msg_token(&self) -> MsgToken;
    fn payload(&self) -> &[u8] ;
    fn options(&self) -> OptionIterator<'_> ;
    fn content_format(&self) -> Option<ContentFormat>;
    fn accept(&self) -> Option<ContentFormat>;
    fn block2(&self) -> Option<BlockInfo>;
    fn block1(&self) -> Option<BlockInfo>;

    // Provided methods
    fn write_msg_to(&self, target: &mut dyn MessageWrite) -> Result<(), Error> { ... }
    fn payload_as_str(&self) -> Option<&str> { ... }
}
Expand description

Trait for reading the various parts of a CoAP message.

Required Methods§

Source

fn msg_code(&self) -> MsgCode

Gets the message code for this message.

Source

fn msg_type(&self) -> MsgType

Gets the message type for this message.

Source

fn msg_id(&self) -> MsgId

Gets the message id for this message.

Source

fn msg_token(&self) -> MsgToken

Gets the message token for this message.

Source

fn payload(&self) -> &[u8]

Gets the payload as a byte slice.

Source

fn options(&self) -> OptionIterator<'_>

Gets an iterator for processing the options of the message.

Source

fn content_format(&self) -> Option<ContentFormat>

Indicates the content format of the payload, if specified.

Source

fn accept(&self) -> Option<ContentFormat>

Indicates the content format that the sender of the message will accept for the payload of the response, if specified.

Source

fn block2(&self) -> Option<BlockInfo>

Returns the value of the block2 option for this message, if any.

Source

fn block1(&self) -> Option<BlockInfo>

Returns the value of the block1 option for this message, if any.

Provided Methods§

Source

fn write_msg_to(&self, target: &mut dyn MessageWrite) -> Result<(), Error>

Writes this message to the given target that implements MessageWrite.

If this message has a message id (msg_id) of zero, the message id will not be written to target.

Source

fn payload_as_str(&self) -> Option<&str>

Gets the payload as a string slice.

Trait Implementations§

Source§

impl<'a> Borrow<dyn MessageRead + 'a> for OwnedImmutableMessage

Source§

fn borrow(&self) -> &(dyn MessageRead + 'a)

Immutably borrows from an owned value. Read more
Source§

impl<'a> ToOwned for dyn MessageRead + 'a

Source§

type Owned = OwnedImmutableMessage

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§