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> { ... }
}
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

Numeric option number

See [OptionNumber] on how to interpret them.

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.

Provided Methods

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.

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.

Implementors