fix: allow all status codes with catch_all
10..69 range is still checked, see comment at L52
This commit is contained in:
parent
0a77d0c2e9
commit
2b6150a8e5
1 changed files with 10 additions and 1 deletions
|
@ -48,6 +48,12 @@ pub enum StatusCode {
|
|||
ClientCerts = 60,
|
||||
CertNotAuthorized = 61,
|
||||
CertNotValid = 62,
|
||||
|
||||
// 1..6 first digit range check is still
|
||||
// covered by conversion into ReplyType
|
||||
// (see Status::parse_status)
|
||||
#[num_enum(catch_all)]
|
||||
Unknown(u8),
|
||||
}
|
||||
|
||||
const ASCII_ZERO: u8 = 48; // '0'
|
||||
|
@ -58,9 +64,12 @@ impl Status {
|
|||
// '2' - '0' = 50 - 48 = 2 (from byte '2' to uint 2)
|
||||
let first = buf[0] - ASCII_ZERO;
|
||||
let second = buf[1] - ASCII_ZERO;
|
||||
|
||||
let code = first * 10 + second;
|
||||
|
||||
Ok(Status {
|
||||
// get enum item for 2-digit status code
|
||||
status_code: StatusCode::try_from_primitive(first * 10 + second)?,
|
||||
status_code: StatusCode::try_from_primitive(code)?,
|
||||
// get enum entry for first digit
|
||||
reply_type: ReplyType::try_from_primitive(first)?,
|
||||
// provide separate field for the 2nd digit
|
||||
|
|
Loading…
Add table
Reference in a new issue