diff --git a/src/status.rs b/src/status.rs index e59bc3e..ca2c59e 100644 --- a/src/status.rs +++ b/src/status.rs @@ -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