Struct toad_msg::msg::opt::OptNumber

source ·
pub struct OptNumber(pub u32);
Expand description

Option Numbers

generated from RFC7252 section 5.4.6

An Option is identified by an option number, which also provides some additional semantics information, e.g., odd numbers indicate a critical option, while even numbers indicate an elective option. Note that this is not just a convention, it is a feature of the protocol: Whether an option is elective or critical is entirely determined by whether its option number is even or odd.

More generally speaking, an Option number is constructed with a bit mask to indicate if an option is Critical or Elective, Unsafe or Safe-to-Forward, and, in the case of Safe-to-Forward, to provide a Cache-Key indication as shown by the following figure. In the following text, the bit mask is expressed as a single byte that is applied to the least significant byte of the option number in unsigned integer representation. When bit 7 (the least significant bit) is 1, an option is Critical (and likewise Elective when 0). When bit 6 is 1, an option is Unsafe (and likewise Safe-to-Forward when 0). When bit 6 is 0, i.e., the option is not Unsafe, it is not a Cache-Key (NoCacheKey) if and only if bits 3-5 are all set to 1; all other bit combinations mean that it indeed is a Cache-Key. These classes of options are explained in the next sections.

                    0   1   2   3   4   5   6   7
                  +---+---+---+---+---+---+---+---+
                  |           | NoCacheKey| U | C |
                  +---+---+---+---+---+---+---+---+

       Figure 10: Option Number Mask (Least Significant Byte)

An endpoint may use an equivalent of the C code in Figure 11 to derive the characteristics of an option number “onum”.

Critical = (onum & 1);
UnSafe = (onum & 2);
NoCacheKey = ((onum & 0x1e) == 0x1c);

    Figure 11: Determining Characteristics from an Option Number

The option numbers for the options defined in this document are listed in the “CoAP Option Numbers” registry (Section 12.2).

RFC7252 Section 12.2 Core CoAP Option Numbers ## CoAP Option Numbers Registry [_generated from RFC7252 section 12.2_](https://datatracker.ietf.org/doc/html/rfc7252#section-12.2)

This document defines a sub-registry for the Option Numbers used in CoAP options within the “CoRE Parameters” registry. The name of the sub-registry is “CoAP Option Numbers”.

Each entry in the sub-registry must include the Option Number, the name of the option, and a reference to the option’s documentation.

Initial entries in this sub-registry are as follows:

              +--------+------------------+-----------+
              | Number | Name             | Reference |
              +--------+------------------+-----------+
              |      0 | (Reserved)       | [RFC7252] |
              |      1 | If-Match         | [RFC7252] |
              |      3 | Uri-Host         | [RFC7252] |
              |      4 | ETag             | [RFC7252] |
              |      5 | If-None-Match    | [RFC7252] |
              |      7 | Uri-Port         | [RFC7252] |
              |      8 | Location-Path    | [RFC7252] |
              |     11 | Uri-Path         | [RFC7252] |
              |     12 | Content-Format   | [RFC7252] |
              |     14 | Max-Age          | [RFC7252] |
              |     15 | Uri-Query        | [RFC7252] |
              |     17 | Accept           | [RFC7252] |
              |     20 | Location-Query   | [RFC7252] |
              |     35 | Proxy-Uri        | [RFC7252] |
              |     39 | Proxy-Scheme     | [RFC7252] |
              |     60 | Size1            | [RFC7252] |
              |    128 | (Reserved)       | [RFC7252] |
              |    132 | (Reserved)       | [RFC7252] |
              |    136 | (Reserved)       | [RFC7252] |
              |    140 | (Reserved)       | [RFC7252] |
              +--------+------------------+-----------+

                    Table 7: CoAP Option Numbers

The IANA policy for future additions to this sub-registry is split into three tiers as follows. The range of 0..255 is reserved for options defined by the IETF (IETF Review or IESG Approval). The range of 256..2047 is reserved for commonly used options with public specifications (Specification Required). The range of 2048..64999 is for all other options including private or vendor-specific ones, which undergo a Designated Expert review to help ensure that the option semantics are defined correctly. The option numbers between 65000 and 65535 inclusive are reserved for experiments. They are not meant for vendor-specific use of any kind and MUST NOT be used in operational deployments.

       +-------------+---------------------------------------+
       |       Range | Registration Procedures               |
       +-------------+---------------------------------------+
       |       0-255 | IETF Review or IESG Approval          |
       |    256-2047 | Specification Required                |
       |  2048-64999 | Expert Review                         |
       | 65000-65535 | Experimental use (no operational use) |
       +-------------+---------------------------------------+

        Table 8: CoAP Option Numbers: Registration Procedures

The documentation of an Option Number should specify the semantics of an option with that number, including the following properties:

o The meaning of the option in a request.

o The meaning of the option in a response.

o Whether the option is critical or elective, as determined by the Option Number.

o Whether the option is Safe-to-Forward, and, if yes, whether it is part of the Cache-Key, as determined by the Option Number (see Section 5.4.2).

o The format and length of the option’s value.

o Whether the option must occur at most once or whether it can occur multiple times.

o The default value, if any. For a critical option with a default value, a discussion on how the default value enables processing by implementations that do not support the critical option (Section 5.4.4).

Tuple Fields§

§0: u32

Implementations§

source§

impl OptNumber

source

pub fn must_be_processed(&self) -> OptionMustBeProcessed

Whether or not this option may be ignored by a server

source

pub fn when_unsupported_by_proxy(&self) -> WhenOptionUnsupportedByProxy

Whether or not this option may be forwarded blindly by a proxy that does not support processing it

source

pub fn when_option_changes(&self) -> WhenOptionChanges

Whether or not different values for this option should yield proxies’ cached response

(when the proxy does not support processing it and the option is safe to forward)

Trait Implementations§

source§

impl Add<OptNumber> for OptNumber

§

type Output = OptNumber

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl Clone for OptNumber

source§

fn clone(&self) -> OptNumber

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for OptNumber

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for OptNumber

source§

fn default() -> OptNumber

Returns the “default value” for a type. Read more
source§

impl Hash for OptNumber

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for OptNumber

source§

fn cmp(&self, other: &OptNumber) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<OptNumber> for OptNumber

source§

fn eq(&self, other: &OptNumber) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<OptNumber> for OptNumber

source§

fn partial_cmp(&self, other: &OptNumber) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Sub<OptNumber> for OptNumber

§

type Output = OptNumber

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
source§

impl Copy for OptNumber

source§

impl Eq for OptNumber

source§

impl StructuralEq for OptNumber

source§

impl StructuralPartialEq for OptNumber

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.