pub(crate) const TABLE: [Entry; 256] = build_lookup_table();
const CHARACTERS: &[u8; 64] = b"!\"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr";
#[derive(Clone, Copy, Debug)]
pub(crate) enum Entry {
Invalid,
Ended,
Ignore,
Valid(u8),
}
const fn build_lookup_table() -> [Entry; 256] {
let mut table = [Entry::Invalid; 256];
table[b':' as usize] = Entry::Ended;
table[b'\r' as usize] = Entry::Ignore;
table[b'\n' as usize] = Entry::Ignore;
let mut i = 0;
loop {
if i == CHARACTERS.len() {
return table;
}
table[CHARACTERS[i] as usize] = Entry::Valid(i as u8);
i += 1;
}
}