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§
Sourcefn options(&self) -> OptionIterator<'_> ⓘ
fn options(&self) -> OptionIterator<'_> ⓘ
Gets an iterator for processing the options of the message.
Sourcefn content_format(&self) -> Option<ContentFormat>
fn content_format(&self) -> Option<ContentFormat>
Indicates the content format of the payload, if specified.
Sourcefn accept(&self) -> Option<ContentFormat>
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.
Provided Methods§
Sourcefn write_msg_to(&self, target: &mut dyn MessageWrite) -> Result<(), Error>
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
.
Sourcefn payload_as_str(&self) -> Option<&str>
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
impl<'a> Borrow<dyn MessageRead + 'a> for OwnedImmutableMessage
Source§fn borrow(&self) -> &(dyn MessageRead + 'a)
fn borrow(&self) -> &(dyn MessageRead + 'a)
Immutably borrows from an owned value. Read more
Source§impl<'a> ToOwned for dyn MessageRead + 'a
impl<'a> ToOwned for dyn MessageRead + 'a
Source§type Owned = OwnedImmutableMessage
type Owned = OwnedImmutableMessage
The resulting type after obtaining ownership.
Source§fn to_owned(&self) -> Self::Owned
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)
fn clone_into(&self, target: &mut Self::Owned)
Uses borrowed data to replace owned data, usually by cloning. Read more