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§
Sourcetype Error: Debug + RenderableOnMinimal
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§
Sourcefn new(option: u16) -> Result<Self, <Self as OptionNumber>::Error>
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.