Skip to main content

EncodedMessage

Trait EncodedMessage 

Source
pub trait EncodedMessage {
    // Required methods
    fn code(&self) -> u8;
    fn options_and_payload(&self) -> &[u8];
}
Expand description

A trait that can implemented on in-memory encoded messages; then, an EncodedMessageView struct can be placed around the implementer to implement coap_message::ReadableMessage.

Implementations must not alter the content returned by the accessors. As this trait is safe to implement, the content of the returned slice could change between calls even when the encoded message was owned or exclusively referenced (e.g. when backed by a RefCell). Therefore, neither this crate nor others can rely on the content upholding any safety guarantees – but it may (and should) panic rater than erring if the expectation of stable content is violated.

Required Methods§

Source

fn code(&self) -> u8

The code of the message

Source

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

The memory area containing the encoded options, payload marker and payload

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§