use crate::{decode_inner, Error};
#[cfg(feature = "alloc")]
use crate::{decoded_len, Vec};
pub fn decode(src: impl AsRef<[u8]>, dst: &mut [u8]) -> Result<&[u8], Error> {
decode_inner(src.as_ref(), dst, decode_nibble)
}
#[cfg(feature = "alloc")]
pub fn decode_vec(input: impl AsRef<[u8]>) -> Result<Vec<u8>, Error> {
let mut output = vec![0u8; decoded_len(input.as_ref())?];
decode(input, &mut output)?;
Ok(output)
}
#[inline(always)]
fn decode_nibble(src: u8) -> u16 {
let byte = src as i16;
let mut ret: i16 = -1;
ret += (((0x2fi16 - byte) & (byte - 0x3a)) >> 8) & (byte - 47);
ret += (((0x40i16 - byte) & (byte - 0x47)) >> 8) & (byte - 54);
ret += (((0x60i16 - byte) & (byte - 0x67)) >> 8) & (byte - 86);
ret as u16
}