pub struct HeapMessage { /* private fields */ }
Expand description

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

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

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

Remove the occurrence’th option of option number optnum

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

Like MinimalWritableMessage::add_option, but allowing arbitrary access

Trait Implementations

Formats the value using the given formatter. Read more
Add an option to the message Read more
Copy code, options and payload in from a readable message Read more
Shortcut for add_option(self, number, value.as_bytes()). Read more
Shortcut for add_option on a buffer containing the uint encoded value Read more
Number of bytes available for additional options, payload marker and payload
👎Deprecated since 0.1.1:

Use payload_mut_with_len instead

Legacy method for mutable access to the payload Read more
Memory-map len bytes of the payload for writing Read more
Truncate an already-set payload to the given length; that payload must have been written to before using MinimalWritableMessage::set_payload, or with a suitable MutableWritableMessage::payload_mut_with_len call. Read more
Apply a callback to all options in sequence Read more
Type of an individual option, indiciating its option number and value
Get the code (request method or response code) of the message Read more
Get the payload set in the message Read more
Produce all options in arbitrary order as an iterator Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.