Struct kwap_msg::Code [−][src]
Expand description
Low-level representation of the code of a message. Identifying it as a request or response
Examples
use kwap_msg::Code;
assert_eq!(Code { class: 2, detail: 5 }.to_string(), "2.05".to_string())See RFC7252 - Message Details for context
Fields
class: u8The “class” of message codes identify it as a request or response, and provides the class of response status:
| class | meaning |
|---|---|
0 | Message is a request |
2 | Message is a success response |
4 | Message is a client error response |
5 | Message is a server error response |
detail: u82-digit integer (range [0, 32)) that provides granular information about the response status.
Will always be 0 for requests.
Implementations
Get the human string representation of a message code
Returns
A char array
This is to avoid unnecessary heap allocation,
you can create a String with FromIterator::<String>::from_iter,
or if the alloc feature of kwap is enabled there is a ToString implementation provided for Code.
use kwap_msg::Code;
let code = Code { class: 2, detail: 5 };
let chars = code.to_human();
let string = String::from_iter(chars);
assert_eq!(string, "2.05".to_string());Trait Implementations
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Code
impl UnwindSafe for Code
Blanket Implementations
Mutably borrows from an owned value. Read more
