Trait coap_message::MessageOption[][src]

pub trait MessageOption {
    fn number(&self) -> u16;
fn value(&self) -> &[u8]; fn value_str(&self) -> Option<&str> { ... }
fn value_uint<U: Ux>(&self) -> Option<U> { ... } }

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

fn number(&self) -> u16[src]

Numeric option number

See [OptionNumber] on how to interpret them.

fn value(&self) -> &[u8][src]

Obtain the option's raw value

This can be used directly for options with opaque value semantics; for other semantics, see the value_str and value_uint helper methods.

Loading content...

Provided methods

fn value_str(&self) -> Option<&str>[src]

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.

fn value_uint<U: Ux>(&self) -> Option<U>[src]

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.

Loading content...

Implementors

impl<'a> MessageOption for MessageOption<'a>[src]

Loading content...