Struct coap_message::heapmessage::HeapMessage [−][src]
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]
&mut self,
optnum: u16,
occurrence: usize,
value: impl Into<Vec<u8>>
)
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
fn set_code(&mut self, code: u8)
[src]
fn add_option(&mut self, optnum: u16, data: &[u8])
[src]
fn set_payload(&mut self, payload: &[u8])
[src]
fn set_from_message<M>(&mut self, msg: &M) where
M: ReadableMessage,
[src]
M: ReadableMessage,
fn add_option_str(&mut self, number: Self::OptionNumber, value: &str)
[src]
fn add_option_uint<U: Ux>(&mut self, number: Self::OptionNumber, value: U)
[src]
impl MutableWritableMessage for HeapMessage
[src]
fn available_space(&self) -> usize
[src]
fn payload_mut(&mut self) -> &mut [u8]
[src]
fn payload_mut_with_len(&mut self, len: usize) -> &mut [u8]
[src]
fn truncate(&mut self, len: usize)
[src]
fn mutate_options<F>(&mut self, mut callback: F) where
F: FnMut(Self::OptionNumber, &mut [u8]),
[src]
F: FnMut(Self::OptionNumber, &mut [u8]),
impl ReadableMessage for HeapMessage
[src]
type Code = u8
See code; also used with MinimalWritableMessage::set_code()
type MessageOption = MessageOption<'a>
Type of an individual option, indiciating its option number and value
type OptionsIter = ReadCursor<'a>
See options
fn code(&self) -> u8
[src]
fn payload(&self) -> &[u8]
[src]
fn options<'m>(&'m self) -> ReadCursor<'m>ⓘNotable traits for ReadCursor<'a>
impl<'a> Iterator for ReadCursor<'a> type Item = MessageOption<'a>;
[src]
Notable traits for ReadCursor<'a>
impl<'a> Iterator for ReadCursor<'a> type Item = MessageOption<'a>;
impl WithSortedOptions for HeapMessage
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,