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 BAD_REQUEST: Self
pub const BAD_REQUEST: Self
4.00 Bad Request.
Sourcepub const UNAUTHORIZED: Self
pub const UNAUTHORIZED: Self
4.01 Unauthorized — client authentication required.
Sourcepub const FORBIDDEN: Self
pub const FORBIDDEN: Self
4.03 Forbidden — authenticated client not authorized for the request.
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).