Struct coap_message::heapmessage::HeapMessage [−][src]
pub struct HeapMessage { /* fields omitted */ }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.
Trait Implementations
type OptionNumber = u16
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
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
See code; also used with MinimalWritableMessage::set_code()
type MessageOption = MessageOption<'a>
type MessageOption = MessageOption<'a>
Type of an individual option, indiciating its option number and value
type OptionsIter = ReadCursor<'a>
type OptionsIter = ReadCursor<'a>
See options
fn options<'m>(&'m self) -> ReadCursor<'m>ⓘNotable traits for ReadCursor<'a>impl<'a> Iterator for ReadCursor<'a> type Item = MessageOption<'a>;
fn options<'m>(&'m self) -> ReadCursor<'m>ⓘNotable traits for ReadCursor<'a>impl<'a> Iterator for ReadCursor<'a> type Item = MessageOption<'a>;
impl<'a> Iterator for ReadCursor<'a> type Item = MessageOption<'a>;Produce all options in arbitrary order as an iterator Read more