spoolframe-types 0.18.0

Spoolframe's client-facing types: the media model and its identifiers.
Documentation
1
2
3
4
5
6
7
8
9
//! PIN syntax shared by clients and servers; authentication remains server-side.

pub const MIN_DIGITS: usize = 4;
pub const MAX_DIGITS: usize = 8;

pub fn pin_digits(pin: &str) -> Option<u8> {
    ((MIN_DIGITS..=MAX_DIGITS).contains(&pin.len()) && pin.bytes().all(|b| b.is_ascii_digit()))
        .then_some(pin.len() as u8)
}