mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
continued porting of test cases
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::common::Result;
|
||||
use crate::qrcode::decoder::ErrorCorrectionLevel;
|
||||
|
||||
impl ErrorCorrectionLevel {
|
||||
pub fn ECLevelFromBits(bits: u8, isMicro: bool) -> Self {
|
||||
pub fn ECLevelFromBitsSigned(bits: i8, isMicro: bool) -> Self {
|
||||
if (isMicro) {
|
||||
let LEVEL_FOR_BITS: [ErrorCorrectionLevel; 8] = [
|
||||
ErrorCorrectionLevel::L,
|
||||
@@ -24,4 +24,8 @@ impl ErrorCorrectionLevel {
|
||||
];
|
||||
return LEVEL_FOR_BITS[bits as usize & 0x3];
|
||||
}
|
||||
|
||||
pub fn ECLevelFromBits(bits: u8, isMicro: bool) -> Self {
|
||||
Self::ECLevelFromBitsSigned(bits as i8, isMicro)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,4 +125,9 @@ impl FormatInformation {
|
||||
pub fn isValid(&self) -> bool {
|
||||
self.hammingDistance <= 3
|
||||
}
|
||||
|
||||
pub fn cpp_eq(&self, other: &Self) -> bool {
|
||||
self.data_mask == other.data_mask
|
||||
&& self.error_correction_level == other.error_correction_level
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,3 +200,32 @@ where
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
impl<T> DecoderResult<T>
|
||||
where
|
||||
T: Copy + Clone + Default + Eq + PartialEq,
|
||||
{
|
||||
pub fn text(&self) -> String {
|
||||
self.content.to_string()
|
||||
}
|
||||
|
||||
pub fn symbologyIdentifier(&self) -> String {
|
||||
let s = self.content.symbology;
|
||||
if s.code > 0 {
|
||||
format!(
|
||||
"]{}{}",
|
||||
vec!['1'; s.code as usize].into_iter().collect::<String>(),
|
||||
char::from(
|
||||
s.modifier
|
||||
+ if self.content.is_eci {
|
||||
s.eciModifierOffset
|
||||
} else {
|
||||
0
|
||||
}
|
||||
)
|
||||
)
|
||||
} else {
|
||||
String::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user