Struct coap_message::heapmessage::HeapMessage[][src]

pub struct HeapMessage { /* fields omitted */ }

A heap CoAP message backed by allocated memory

It stores its payload in a Vec, and uses a BTreeMap<_, Vec<_>> to store all the individual option values.

It offers a few methods for direct manipulation of options, even out of sequence, that can not be expected from a general message buffer and are thus not captured in traits.

let mut m = HeapMessage::new();
m.set_code(1);
m.add_option(11, b".well-known");
m.add_option(11, b"core");

let mut m2 = HeapMessage::new();
m2.set_from_message(&m);
assert!(m.code() == 1);

Implementations

impl HeapMessage[src]

pub fn new() -> Self[src]

pub fn change_option(
    &mut self,
    optnum: u16,
    occurrence: usize,
    value: impl Into<Vec<u8>>
)
[src]

Replace the occurrence'th value of the optnum option in the message

Panics if there's not occurrence + 1 options of that number.

pub fn remove_option(&mut self, optnum: u16, occurrence: usize)[src]

Remove the occurrence'th option of option number optnum

Panics if there's not occurrence + 1 options of that number.

pub fn add_option(&mut self, optnum: u16, data: &[u8])[src]

Like MinimalWritableMessage::add_option, but allowing arbitrary access

Trait Implementations

impl Debug for HeapMessage[src]

impl MinimalWritableMessage for HeapMessage[src]

type Code = u8

type OptionNumber = u16

impl MutableWritableMessage for HeapMessage[src]

impl ReadableMessage for HeapMessage[src]

type Code = u8

type MessageOption = MessageOption<'a>

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

type OptionsIter = ReadCursor<'a>

See options

impl WithSortedOptions for HeapMessage[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.