mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
continue removing todo!()s
This commit is contained in:
@@ -66,7 +66,7 @@ impl Version {
|
||||
return Err(Exceptions::ILLEGAL_STATE);
|
||||
}
|
||||
|
||||
pub fn isMicroQRCode(&self) -> bool {
|
||||
pub const fn isMicroQRCode(&self) -> bool {
|
||||
self.is_micro
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,12 +47,14 @@ where
|
||||
Self::default()
|
||||
}
|
||||
pub fn with_eci_string_builder(src: ECIStringBuilder) -> Self {
|
||||
todo!()
|
||||
let mut new_self = Self::default();
|
||||
new_self.content = src;
|
||||
new_self
|
||||
}
|
||||
|
||||
pub fn isValid(&self) -> bool {
|
||||
self.content.symbology.code != 0
|
||||
//return includeErrors || (_content.symbology.code != 0 && !_error);
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn content(&self) -> &ECIStringBuilder {
|
||||
|
||||
@@ -306,7 +306,7 @@ pub fn DecodeBitStream(
|
||||
mode = Mode::CodecModeForBits(
|
||||
bits.readBits(modeBitLength as usize)?,
|
||||
Some(version.isMicroQRCode()),
|
||||
);
|
||||
)?;
|
||||
}
|
||||
|
||||
match (mode) {
|
||||
|
||||
@@ -123,10 +123,18 @@ impl Mode {
|
||||
}
|
||||
|
||||
pub const fn get_terminator_bit_length(version: &Version) -> u8 {
|
||||
todo!()
|
||||
(if version.isMicroQRCode() {
|
||||
version.getVersionNumber() * 2 + 1
|
||||
} else {
|
||||
4
|
||||
}) as u8
|
||||
}
|
||||
pub const fn get_codec_mode_bits_length(version: &Version) -> u8 {
|
||||
todo!()
|
||||
(if version.isMicroQRCode() {
|
||||
version.getVersionNumber() - 1
|
||||
} else {
|
||||
4
|
||||
}) as u8
|
||||
}
|
||||
/**
|
||||
* @param bits variable number of bits encoding a QR Code data mode
|
||||
@@ -134,9 +142,23 @@ impl Mode {
|
||||
* @return Mode encoded by these bits
|
||||
* @throws FormatError if bits do not correspond to a known mode
|
||||
*/
|
||||
pub fn CodecModeForBits(bits: u32, isMicro: Option<bool>) -> Self {
|
||||
pub fn CodecModeForBits(bits: u32, isMicro: Option<bool>) -> Result<Self> {
|
||||
let isMicro = isMicro.unwrap_or(false);
|
||||
todo!()
|
||||
const BITS_2_MODE_LEN: usize = 4;
|
||||
|
||||
if (!isMicro) {
|
||||
if ((bits >= 0x00 && bits <= 0x05) || (bits >= 0x07 && bits <= 0x09) || bits == 0x0d) {
|
||||
return Mode::try_from(bits);
|
||||
}
|
||||
} else {
|
||||
const Bits2Mode: [Mode; BITS_2_MODE_LEN] =
|
||||
[Mode::NUMERIC, Mode::ALPHANUMERIC, Mode::BYTE, Mode::KANJI];
|
||||
if ((bits as usize) < BITS_2_MODE_LEN) {
|
||||
return Ok(Bits2Mode[bits as usize]);
|
||||
}
|
||||
}
|
||||
|
||||
Err(Exceptions::format_with("Invalid codec mode"))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,3 +184,11 @@ impl TryFrom<u8> for Mode {
|
||||
Self::forBits(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<u32> for Mode {
|
||||
type Error = Exceptions;
|
||||
|
||||
fn try_from(value: u32) -> Result<Self, Self::Error> {
|
||||
Self::forBits(value as u8)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ impl Version {
|
||||
alignmentPatternCenters,
|
||||
ecBlocks: ecBlocks.to_vec(),
|
||||
totalCodewords: total,
|
||||
is_micro: false
|
||||
is_micro: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,11 +91,11 @@ impl Version {
|
||||
alignmentPatternCenters: Vec::default(),
|
||||
ecBlocks,
|
||||
totalCodewords: total,
|
||||
is_micro: true
|
||||
is_micro: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn getVersionNumber(&self) -> u32 {
|
||||
pub const fn getVersionNumber(&self) -> u32 {
|
||||
self.versionNumber
|
||||
}
|
||||
|
||||
@@ -206,9 +206,28 @@ impl Version {
|
||||
pub fn build_micro_versions() -> Vec<Version> {
|
||||
vec![
|
||||
Version::new_micro(1, vec![ECBlocks::new(2, vec![ECB::new(1, 3)])]),
|
||||
Version::new_micro(2, vec![ECBlocks::new(5, vec![ECB::new(1,5)]), ECBlocks::new(6, vec![ECB::new(1,4)])]),
|
||||
Version::new_micro(3, vec![ECBlocks::new(6, vec![ECB::new(1,11)]), ECBlocks::new(8, vec![ECB::new(1,9)])]),
|
||||
Version::new_micro(4, vec![ECBlocks::new(8, vec![ECB::new(1,16)]), ECBlocks::new(10, vec![ECB::new(1,14)]), ECBlocks::new(14, vec![ECB::new(1,10)])]),
|
||||
Version::new_micro(
|
||||
2,
|
||||
vec![
|
||||
ECBlocks::new(5, vec![ECB::new(1, 5)]),
|
||||
ECBlocks::new(6, vec![ECB::new(1, 4)]),
|
||||
],
|
||||
),
|
||||
Version::new_micro(
|
||||
3,
|
||||
vec![
|
||||
ECBlocks::new(6, vec![ECB::new(1, 11)]),
|
||||
ECBlocks::new(8, vec![ECB::new(1, 9)]),
|
||||
],
|
||||
),
|
||||
Version::new_micro(
|
||||
4,
|
||||
vec![
|
||||
ECBlocks::new(8, vec![ECB::new(1, 16)]),
|
||||
ECBlocks::new(10, vec![ECB::new(1, 14)]),
|
||||
ECBlocks::new(14, vec![ECB::new(1, 10)]),
|
||||
],
|
||||
),
|
||||
]
|
||||
// static const Version allVersions[] = {
|
||||
// {1, {2, 1, 3, 0, 0}},
|
||||
|
||||
Reference in New Issue
Block a user