coap_message

Trait OptionNumber

Source
pub trait OptionNumber: Into<u16> + TryFrom<u16> {
    type Error: Debug + RenderableOnMinimal;

    // Required method
    fn new(option: u16) -> Result<Self, <Self as OptionNumber>::Error>;
}
Expand description

A CoAP option number

For its meaning, see the CoAP Option Numbers IANA subregistry or the coap_numbers::option module that lists them, and provides helpers for decoding their properties.

In analogy to Code, these are convertible to u16 and fallibly convertible from there.

Required Associated Types§

Source

type Error: Debug + RenderableOnMinimal

Error of the .new() method; ideally, this is also the TryFrom::Error (which can not be restricted without Associated type bounds being stabilized).

Once that is available, the built-in new method will be deprecated and eventually removed – a change that will be trivial on code using it provided that this error is indeed the error of TryFrom.

The error, when rendered, should represent a 5.00 style error, because what went wrong was that the server handler attempted to use a CoAP option which the server could not represent.

Required Methods§

Source

fn new(option: u16) -> Result<Self, <Self as OptionNumber>::Error>

This constructor is a more concrete variant of the TryFrom function whose error code is practically usable (see Self::Error)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl OptionNumber for u16

Implementors§