Skip to main content

MessageBuffer

Trait MessageBuffer 

Source
pub trait MessageBuffer {
    // Required methods
    fn code(&self) -> u8;
    fn tail(&self) -> &[u8];

    // Provided method
    fn static_variant(    ) -> Option<LifetimesMatterLittle<impl 'static + MessageBuffer>> { ... }
}
Expand description

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

Implementations must not alter the content returned by the accessors. As this trait is safe to implement, the content of the returned slice might 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 unsafe 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 tail(&self) -> &[u8]

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

Provided Methods§

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl MessageBuffer for Infallible

Source§

fn code(&self) -> u8

Source§

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

Implementors§

Source§

impl MessageBuffer for BoxBuffer

Available on crate feature alloc only.
Source§

impl MessageBuffer for SliceBuffer<'_>

Source§

impl MessageBuffer for SliceBufferMut<'_>