Skip to main content

CoapCode

Struct CoapCode 

Source
pub struct CoapCode {
    pub class: u8,
    pub detail: u8,
}
Expand description

CoAP-Code (RFC 7252 §3 + §12.1) — 8-bit, 3-bit class + 5-bit detail.

Format c.dd mit c ∈ 0..=7 und dd ∈ 0..=31.

Code-Class:

  • 0 — Request (0.00 = empty, 0.01-0.04 = method codes).
  • 2 — Success Response.
  • 4 — Client Error.
  • 5 — Server Error.

Fields§

§class: u8

3-bit class.

§detail: u8

5-bit detail.

Implementations§

Source§

impl CoapCode

Source

pub const EMPTY: Self

EMPTY (0.00, RFC 7252 §3) — Spec-Sonderfall fuer Reset/ACK.

Source

pub const GET: Self

GET (0.01).

Source

pub const POST: Self

POST (0.02).

Source

pub const PUT: Self

PUT (0.03).

Source

pub const DELETE: Self

DELETE (0.04).

Source

pub const CREATED: Self

2.01 Created.

Source

pub const DELETED: Self

2.02 Deleted.

Source

pub const VALID: Self

2.03 Valid.

Source

pub const CHANGED: Self

2.04 Changed.

Source

pub const CONTENT: Self

2.05 Content.

Source

pub const BAD_REQUEST: Self

4.00 Bad Request.

Source

pub const NOT_FOUND: Self

4.04 Not Found.

Source

pub const INTERNAL_SERVER_ERROR: Self

5.00 Internal Server Error.

Source

pub const fn new(class: u8, detail: u8) -> Self

Konstruktor; class+detail werden auf gueltige Bit-Bereiche (3-bit, 5-bit) gemaskt.

Source

pub const fn from_byte(b: u8) -> Self

Decodiert vom Wire-Byte (RFC 7252 §3 Code-Field).

Source

pub const fn to_byte(self) -> u8

Encodiert ins Wire-Byte.

Source

pub const fn is_request(self) -> bool

true wenn class == 0 und detail > 0 — Request-Method (Spec §3 + §12.1.1).

Source

pub const fn is_success(self) -> bool

true wenn class == 2 — Success-Response (Spec §12.1.2).

Source

pub const fn is_client_error(self) -> bool

true wenn class == 4 — Client-Error (Spec §12.1.2).

Source

pub const fn is_server_error(self) -> bool

true wenn class == 5 — Server-Error (Spec §12.1.2).

Source

pub const fn is_empty(self) -> bool

true wenn Empty-Code (0.00).

Trait Implementations§

Source§

impl Clone for CoapCode

Source§

fn clone(&self) -> CoapCode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CoapCode

Source§

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

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

impl Display for CoapCode

Source§

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

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

impl Hash for CoapCode

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 PartialEq for CoapCode

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for CoapCode

Source§

impl Eq for CoapCode

Source§

impl StructuralPartialEq for CoapCode

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.