pub struct CoapCode {
pub class: u8,
pub detail: u8,
}Expand description
CoAP response/request code (RFC 7252 §3, §5.9).
Encoded as a single byte: upper 3 bits = class, lower 5 bits = detail.
Conventionally written as class.detail (e.g., 2.05 = Content).
Fields§
§class: u8Code class (0 = request, 2 = success, 4 = client error, 5 = server error).
detail: u8Code detail within the class.
Implementations§
Source§impl CoapCode
impl CoapCode
Sourcepub const METHOD_NOT_ALLOWED: Self
pub const METHOD_NOT_ALLOWED: Self
4.05 Method Not Allowed — wrong method for resource.
Sourcepub const UNSUPPORTED_CONTENT_FORMAT: Self
pub const UNSUPPORTED_CONTENT_FORMAT: Self
4.15 Unsupported Content-Format.
Sourcepub const INTERNAL_SERVER_ERROR: Self
pub const INTERNAL_SERVER_ERROR: Self
5.00 Internal Server Error.
Sourcepub fn to_byte(&self) -> u8
pub fn to_byte(&self) -> u8
Encodes the code as a single byte: class in bits 7-5, detail in bits 4-0.
Sourcepub fn is_request(&self) -> bool
pub fn is_request(&self) -> bool
Returns whether this code represents a request (class 0).
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns whether this code represents a success response (class 2).
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Returns whether this code represents a client error (class 4).
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Returns whether this code represents a server error (class 5).
Trait Implementations§
impl Copy for CoapCode
impl Eq for CoapCode
impl StructuralPartialEq for CoapCode
Auto Trait Implementations§
impl Freeze for CoapCode
impl RefUnwindSafe for CoapCode
impl Send for CoapCode
impl Sync for CoapCode
impl Unpin for CoapCode
impl UnsafeUnpin for CoapCode
impl UnwindSafe for CoapCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more