(input: &[u8])
| 165 | } |
| 166 | |
| 167 | fn array2_parser(input: &[u8]) -> IResult<&[u8], (Cmd<'_>, usize)> { |
| 168 | // The *2 parser then checks the first element |
| 169 | // AUTH |
| 170 | // then it can stuff the second into the resp. |
| 171 | // etc |
| 172 | // |
| 173 | let mut taken = 0; |
| 174 | |
| 175 | let (rem, (ln, sz)) = line_parser(input)?; |
| 176 | |
| 177 | taken += sz; |
| 178 | |
| 179 | tag("*2")(ln)?; |
| 180 | |
| 181 | // What is the next value? That tells us if we should proceed now or not. |
| 182 | let (rem, (itype1, sz)) = type_parser(rem)?; |
| 183 | taken += sz; |
| 184 | |
| 185 | match itype1 { |
| 186 | IType::BulkString(b"AUTH") => { |
| 187 | let (rem, (itype2, sz)) = type_parser(rem)?; |
| 188 | taken += sz; |
| 189 | |
| 190 | trace!("array2_parser - taken {:?}", taken); |
| 191 | |
| 192 | match itype2 { |
| 193 | IType::BulkString(pw) => Ok((rem, (Cmd::Auth(pw), taken))), |
| 194 | // _ => Ok((rem, (Cmd::Disconnect, taken))), |
| 195 | } |
| 196 | } |
| 197 | IType::BulkString(b"GET") => { |
| 198 | let (rem, (itype2, sz)) = type_parser(rem)?; |
| 199 | taken += sz; |
| 200 | |
| 201 | trace!("array2_parser - taken {:?}", taken); |
| 202 | |
| 203 | match itype2 { |
| 204 | IType::BulkString(k) => Ok((rem, (Cmd::Get(k), taken))), |
| 205 | // _ => Ok((rem, (Cmd::Disconnect, taken))), |
| 206 | } |
| 207 | } |
| 208 | _ => Ok((rem, (Cmd::Disconnect, taken))), |
| 209 | } |
| 210 | |
| 211 | // do a "first value" parse, capable of reading if it's bulk or simple string. |
| 212 | // once we know the first value, can understand the second. |
| 213 | } |
| 214 | |
| 215 | fn array1_parser(input: &[u8]) -> IResult<&[u8], (Cmd<'_>, usize)> { |
| 216 | let mut taken = 0; |
nothing calls this directly
no test coverage detected