Skip to content

Commit

Permalink
fix: Mode was not public
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanvivien committed May 14, 2024
1 parent 4c0a798 commit eaa38b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ use crate::version::Version;
/// Enum for the 3 encoding mode
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Mode {
/// Numeric mode (0-9 only)
Numeric,
/// Alphanumeric mode (0-9, A-Z, $%*./:+-?.= [space])
Alphanumeric,
/// Byte mode (any)
Byte,
}

Expand Down Expand Up @@ -152,7 +155,12 @@ fn pad_to_8(compact: &mut CompactQR) {

/// Converts ascii number to it's value in usize \
/// "5" -> 5
const fn ascii_to_digit(c: u8) -> usize {
fn ascii_to_digit(c: u8) -> usize {
assert!(
c.is_ascii_digit(),
"Unexpected character '{}' in Numeric mode",
c as char
);
(c - b'0') as usize
}

Expand All @@ -172,7 +180,7 @@ pub(crate) fn ascii_to_alphanumeric(c: u8) -> usize {
b'.' => 42,
b'/' => 43,
b':' => 44,
_ => panic!("Character '{}' should not occur", c as char), // unreachable!()
_ => panic!("Unexpected haracter '{}' in Alphanumeric mode", c as char),
}
}

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@

pub use crate::datamasking::Mask;
pub use crate::ecl::ECL;
pub use crate::encode::Mode;
pub use crate::module::{Module, ModuleType};
pub use crate::qr::{QRBuilder, QRCode};
pub use crate::version::Version;
Expand Down

0 comments on commit eaa38b9

Please sign in to comment.