Trait coap_message::MessageOption
source · pub trait MessageOption {
// Required methods
fn number(&self) -> u16;
fn value(&self) -> &[u8] ⓘ;
// Provided methods
fn value_str(&self) -> Option<&str> { ... }
fn value_uint<U>(&self) -> Option<U>
where U: Unsigned + FromBytes,
U::Bytes: Sized + Default { ... }
}
Expand description
Iteration item for option values
An implementation needs to allow the user to get the value as a memory slice. This is trivial
for messages that are stored in serialized form. Implementations that store options
semantically (eg. as a struct Block { n: usize, m: bool, szx: u8 }
) will typically make their
MessageOption large enough to contain serialized options, or heap-allocate for them.
Required Methods§
Provided Methods§
sourcefn value_str(&self) -> Option<&str>
fn value_str(&self) -> Option<&str>
Obtain the option’s value as a text string, or None if the option contains invalid UTF-8.
Implementations can override this to reduce the string checking overhead if they already have the value as a string internally.
sourcefn value_uint<U>(&self) -> Option<U>
fn value_uint<U>(&self) -> Option<U>
Obtain the option’s value as a number following the uint
value
format, or None if the option is too
long.
Implementations can override this to reduce conversion overhead if they already have a numeric value internally as soon as U’s type is replaced with an equally capable public num trait.