Function coap_numbers::code::to_dotted

source ·
pub fn to_dotted(code: u8) -> String
Available on crate feature alloc only.
Expand description

Convert a CoAP code to dotted notation

This expresses the class number of a code, followed by a dot and the two-digit detail, into a String. That format is the common human-readable expression of CoAP codes, as it eases the comparison to the (dot-less) codes of HTTP.

Example:

let g: String = to_dotted(GET);
assert_eq!(g, "0.01");
let d = to_dotted(PRECONDITION_FAILED);
assert_eq!(d, "4.12");

This is equivalent in functionality to format_dotted, which may be used as a replacement in no_std settings.