pub trait ReadableMessage {
    type Code: Code;
    type MessageOption<'a>: MessageOption
       where Self: 'a;
    type OptionsIter<'a>: Iterator<Item = Self::MessageOption<'a>>
       where Self: 'a;

    // Required methods
    fn code(&self) -> Self::Code;
    fn payload(&self) -> &[u8] ;
    fn options(&self) -> Self::OptionsIter<'_>;
}
Expand description

A CoAP message whose code, options and payload can be read

Required Associated Types§

source

type Code: Code

source

type MessageOption<'a>: MessageOption where Self: 'a

Type of an individual option, indiciating its option number and value

source

type OptionsIter<'a>: Iterator<Item = Self::MessageOption<'a>> where Self: 'a

See options

Required Methods§

source

fn code(&self) -> Self::Code

Get the code (request method or response code) of the message

See [Code] for its meaning.

source

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

Get the payload set in the message

This is necessarily empty for messages of some codes.

source

fn options(&self) -> Self::OptionsIter<'_>

Produce all options in arbitrary order as an iterator

If your options are always produced in an ordered fashion, consider implementing the WithSortedOptions trait as well. This should be the case for most CoAP message backends. Examples of backends where it is not implemented are single-pass reads over in-place decrypted OSCORE messages.

Object Safety§

This trait is not object safe.

Implementors§