many warnings cleaned up

This commit is contained in:
Henry Schimke
2022-12-30 16:19:45 -06:00
parent 6a9ac8fa89
commit b383d7b0d4
48 changed files with 107 additions and 127 deletions

View File

@@ -9,6 +9,7 @@ lazy_static! {
static ref DOTX: Regex = Regex::new("[^.X]").unwrap(); static ref DOTX: Regex = Regex::new("[^.X]").unwrap();
} }
#[allow(dead_code)]
pub fn toBitArray(bits: &str) -> BitArray { pub fn toBitArray(bits: &str) -> BitArray {
let mut ba_in = BitArray::new(); let mut ba_in = BitArray::new();
let str = DOTX.replace_all(bits, ""); let str = DOTX.replace_all(bits, "");
@@ -20,6 +21,7 @@ pub fn toBitArray(bits: &str) -> BitArray {
ba_in ba_in
} }
#[allow(dead_code)]
pub fn toBooleanArray(bitArray: &BitArray) -> Vec<bool> { pub fn toBooleanArray(bitArray: &BitArray) -> Vec<bool> {
let mut result = vec![false; bitArray.getSize()]; let mut result = vec![false; bitArray.getSize()];
for i in 0..result.len() { for i in 0..result.len() {
@@ -29,6 +31,7 @@ pub fn toBooleanArray(bitArray: &BitArray) -> Vec<bool> {
result result
} }
#[allow(dead_code)]
pub fn stripSpace(s: &str) -> String { pub fn stripSpace(s: &str) -> String {
SPACES.replace_all(s, "").to_string() SPACES.replace_all(s, "").to_string()
} }

View File

@@ -37,7 +37,7 @@ use std::collections::HashMap;
use crate::BarcodeFormat; use crate::BarcodeFormat;
use super::{ use super::{
ExpandedProductParsedRXingResult, ExpandedProductParsedResult, ParsedClientResult, ResultParser, ExpandedProductParsedRXingResult, ParsedClientResult, ResultParser,
}; };
/** /**

View File

@@ -70,7 +70,7 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<super::ParsedClientR
// is 'true' or 'false': // is 'true' or 'false':
let mut hidden = false; let mut hidden = false;
let mut phase2Method = ResultParser::matchSinglePrefixedField("PH2:", &rawText, ';', false); let mut phase2Method = ResultParser::matchSinglePrefixedField("PH2:", &rawText, ';', false);
let hValue = if let Some(hv) = let _hValue = if let Some(hv) =
ResultParser::matchSinglePrefixedField("H:", &rawText, ';', false) ResultParser::matchSinglePrefixedField("H:", &rawText, ';', false)
{ {
// If PH2 was specified separately, or if the value is clearly boolean, interpret it as 'hidden' // If PH2 was specified separately, or if the value is clearly boolean, interpret it as 'hidden'

View File

@@ -269,7 +269,7 @@ fn test_parse_boolean() {
fullMatrix.setRegion(0, 0, 3, 3).expect("must set"); fullMatrix.setRegion(0, 0, 3, 3).expect("must set");
let mut centerMatrix = BitMatrix::new(3, 3).unwrap(); let mut centerMatrix = BitMatrix::new(3, 3).unwrap();
centerMatrix.setRegion(1, 1, 1, 1).expect("must set"); centerMatrix.setRegion(1, 1, 1, 1).expect("must set");
let emptyMatrix24 = BitMatrix::new(2, 4).unwrap(); let _emptyMatrix24 = BitMatrix::new(2, 4).unwrap();
let mut matrix = vec![vec![false; 3]; 3]; let mut matrix = vec![vec![false; 3]; 3];
// boolean[][] matrix = new boolean[3][3]; // boolean[][] matrix = new boolean[3][3];

View File

@@ -19,7 +19,7 @@ use std::collections::HashMap;
use crate::{ use crate::{
common::{BitMatrix, DetectorRXingResult}, common::{BitMatrix, DetectorRXingResult},
BarcodeFormat, DecodeHintType, Exceptions, RXingResult, RXingResultMetadataType, BarcodeFormat, DecodeHintType, Exceptions, RXingResult, RXingResultMetadataType,
RXingResultMetadataValue, RXingResultPoint, Reader, RXingResultMetadataValue, Reader,
}; };
use super::{decoder::Decoder, detector::Detector}; use super::{decoder::Decoder, detector::Detector};
@@ -27,7 +27,7 @@ use super::{decoder::Decoder, detector::Detector};
use lazy_static::lazy_static; use lazy_static::lazy_static;
lazy_static! { lazy_static! {
static ref decoder: Decoder = Decoder::new(); static ref DECODER: Decoder = Decoder::new();
} }
/** /**
@@ -74,11 +74,11 @@ impl Reader for DataMatrixReader {
let mut points = Vec::new(); let mut points = Vec::new();
if hints.contains_key(&DecodeHintType::PURE_BARCODE) { if hints.contains_key(&DecodeHintType::PURE_BARCODE) {
let bits = self.extractPureBits(image.getBlackMatrix())?; let bits = self.extractPureBits(image.getBlackMatrix())?;
decoderRXingResult = decoder.decode(&bits)?; decoderRXingResult = DECODER.decode(&bits)?;
points.clear(); points.clear();
} else { } else {
let detectorRXingResult = Detector::new(image.getBlackMatrix().clone())?.detect()?; let detectorRXingResult = Detector::new(image.getBlackMatrix().clone())?.detect()?;
decoderRXingResult = decoder.decode(detectorRXingResult.getBits())?; decoderRXingResult = DECODER.decode(detectorRXingResult.getBits())?;
points = detectorRXingResult.getPoints().clone(); points = detectorRXingResult.getPoints().clone();
} }
let mut result = RXingResult::new( let mut result = RXingResult::new(

View File

@@ -589,7 +589,7 @@ fn decodeEdifactSegment(
// Read rest of byte, which should be 0, and stop // Read rest of byte, which should be 0, and stop
let bitsLeft = 8 - bits.getBitOffset(); let bitsLeft = 8 - bits.getBitOffset();
if bitsLeft != 8 { if bitsLeft != 8 {
bits.readBits(bitsLeft); bits.readBits(bitsLeft)?;
} }
return Ok(()); return Ok(());
} }
@@ -633,9 +633,10 @@ fn decodeBase256Segment(
} }
// We're seeing NegativeArraySizeException errors from users. // We're seeing NegativeArraySizeException errors from users.
if count < 0 { // but we shouldn't in rust because it's unsigned
return Err(Exceptions::FormatException("".to_owned())); // if count < 0 {
} // return Err(Exceptions::FormatException("".to_owned()));
// }
let mut bytes = vec![0u8; count as usize]; let mut bytes = vec![0u8; count as usize];
for i in 0..count as usize { for i in 0..count as usize {

View File

@@ -49,7 +49,7 @@ impl Encoder for X12Encoder {
} }
} }
} }
Self::handleEOD(context, &mut buffer); Self::handleEOD(context, &mut buffer)?;
Ok(()) Ok(())
} }
} }
@@ -70,7 +70,7 @@ impl X12Encoder {
} else if c >= 'A' && c <= 'Z' { } else if c >= 'A' && c <= 'Z' {
sb.push((c as u8 - 65 + 14) as char); sb.push((c as u8 - 65 + 14) as char);
} else { } else {
high_level_encoder::illegalCharacter(c); high_level_encoder::illegalCharacter(c).expect("detect_illegal_character");
} }
} }
} }

View File

@@ -86,10 +86,10 @@ pub trait LuminanceSource {
*/ */
fn crop( fn crop(
&self, &self,
left: usize, _left: usize,
top: usize, _top: usize,
width: usize, _width: usize,
height: usize, _height: usize,
) -> Result<Box<dyn LuminanceSource>, Exceptions> { ) -> Result<Box<dyn LuminanceSource>, Exceptions> {
return Err(Exceptions::UnsupportedOperationException( return Err(Exceptions::UnsupportedOperationException(
"This luminance source does not support cropping.".to_owned(), "This luminance source does not support cropping.".to_owned(),

View File

@@ -17,7 +17,7 @@
use std::{collections::HashSet, path::PathBuf, rc::Rc}; use std::{collections::HashSet, path::PathBuf, rc::Rc};
use crate::{ use crate::{
common::HybridBinarizer, qrcode::QRCodeReader, BarcodeFormat, BinaryBitmap, common::HybridBinarizer, BarcodeFormat, BinaryBitmap,
BufferedImageLuminanceSource, MultiFormatReader, BufferedImageLuminanceSource, MultiFormatReader,
}; };

View File

@@ -15,7 +15,7 @@
*/ */
use crate::{ use crate::{
common::{BitMatrix, DetectorRXingResult}, common::{BitMatrix},
qrcode::detector::{Detector, QRCodeDetectorResult}, qrcode::detector::{Detector, QRCodeDetectorResult},
DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
}; };

View File

@@ -19,7 +19,7 @@ use std::cmp::Ordering;
use crate::{ use crate::{
common::BitMatrix, common::BitMatrix,
qrcode::detector::{FinderPattern, FinderPatternFinder, FinderPatternInfo}, qrcode::detector::{FinderPattern, FinderPatternFinder, FinderPatternInfo},
result_point_utils, DecodeHintType, DecodingHintDictionary, Exceptions, RXingResultPoint, result_point_utils, DecodeHintType, DecodingHintDictionary, Exceptions,
RXingResultPointCallback, RXingResultPointCallback,
}; };

View File

@@ -169,7 +169,6 @@ impl Default for CodaBarWriter {
mod CodaBarWriterTestCase { mod CodaBarWriterTestCase {
use crate::{ use crate::{
common::{BitMatrix, BitMatrixTestCase}, common::{BitMatrix, BitMatrixTestCase},
oned::OneDimensionalCodeWriter,
BarcodeFormat, Writer, BarcodeFormat, Writer,
}; };

View File

@@ -18,7 +18,7 @@ use one_d_proc_derive::OneDWriter;
use crate::BarcodeFormat; use crate::BarcodeFormat;
use super::{code_128_reader, Code128Reader, OneDimensionalCodeWriter, CODE_PATTERNS}; use super::{code_128_reader, OneDimensionalCodeWriter};
const CODE_START_A: usize = 103; const CODE_START_A: usize = 103;
const CODE_START_B: usize = 104; const CODE_START_B: usize = 104;

View File

@@ -44,7 +44,7 @@ use crate::{
use super::Code128Writer; use super::Code128Writer;
lazy_static! { lazy_static! {
static ref writer: Code128Writer = Code128Writer::default(); static ref WRITER: Code128Writer = Code128Writer::default();
} }
#[test] #[test]
@@ -330,7 +330,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetABadCharacter() {
EncodeHintType::FORCE_CODE_SET, EncodeHintType::FORCE_CODE_SET,
EncodeHintValue::ForceCodeSet("A".to_string()), EncodeHintValue::ForceCodeSet("A".to_string()),
); );
writer WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints) .encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode"); .expect("encode");
} }
@@ -348,7 +348,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetBBadCharacter() {
); );
// let hints = new EnumMap<>(EncodeHintType.class); // let hints = new EnumMap<>(EncodeHintType.class);
// hints.put(EncodeHintType.FORCE_CODE_SET, "B"); // hints.put(EncodeHintType.FORCE_CODE_SET, "B");
writer WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints) .encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode"); .expect("encode");
} }
@@ -366,7 +366,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetCBadCharactersNonNum() {
); );
// let hints = new EnumMap<>(EncodeHintType.class); // let hints = new EnumMap<>(EncodeHintType.class);
// hints.put(EncodeHintType.FORCE_CODE_SET, "C"); // hints.put(EncodeHintType.FORCE_CODE_SET, "C");
writer WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints) .encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode"); .expect("encode");
} }
@@ -382,7 +382,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetCBadCharactersFncCode() {
EncodeHintType::FORCE_CODE_SET, EncodeHintType::FORCE_CODE_SET,
EncodeHintValue::ForceCodeSet("C".to_string()), EncodeHintValue::ForceCodeSet("C".to_string()),
); );
writer WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints) .encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode"); .expect("encode");
} }
@@ -398,7 +398,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetCWrongAmountOfDigits() {
EncodeHintType::FORCE_CODE_SET, EncodeHintType::FORCE_CODE_SET,
EncodeHintValue::ForceCodeSet("C".to_string()), EncodeHintValue::ForceCodeSet("C".to_string()),
); );
writer WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints) .encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode"); .expect("encode");
} }
@@ -429,7 +429,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetA() {
EncodeHintType::FORCE_CODE_SET, EncodeHintType::FORCE_CODE_SET,
EncodeHintValue::ForceCodeSet("A".to_string()), EncodeHintValue::ForceCodeSet("A".to_string()),
); );
let result = writer let result = WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints) .encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode"); .expect("encode");
@@ -462,7 +462,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetB() {
EncodeHintType::FORCE_CODE_SET, EncodeHintType::FORCE_CODE_SET,
EncodeHintValue::ForceCodeSet("B".to_string()), EncodeHintValue::ForceCodeSet("B".to_string()),
); );
let result = writer let result = WRITER
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints) .encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
.expect("encode"); .expect("encode");
@@ -481,7 +481,7 @@ fn encode(toEncode: &str, compact: bool, expectedLoopback: &str) -> Result<BitMa
); );
} }
let encRXingResult = let encRXingResult =
writer.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)?; WRITER.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)?;
if !expectedLoopback.is_empty() { if !expectedLoopback.is_empty() {
let row = encRXingResult.getRow(0, BitArray::new()); let row = encRXingResult.getRow(0, BitArray::new());
let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?; let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?;
@@ -493,7 +493,7 @@ fn encode(toEncode: &str, compact: bool, expectedLoopback: &str) -> Result<BitMa
let row = encRXingResult.getRow(0, BitArray::new()); let row = encRXingResult.getRow(0, BitArray::new());
let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?; let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?;
let actual = rtRXingResult.getText(); let actual = rtRXingResult.getText();
let encRXingResultFast = writer.encode(toEncode, &BarcodeFormat::CODE_128, 0, 0)?; let encRXingResultFast = WRITER.encode(toEncode, &BarcodeFormat::CODE_128, 0, 0)?;
let row = encRXingResultFast.getRow(0, BitArray::new()); let row = encRXingResultFast.getRow(0, BitArray::new());
let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?; let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?;
assert_eq!(rtRXingResult.getText(), actual); assert_eq!(rtRXingResult.getText(), actual);

View File

@@ -95,12 +95,13 @@ impl Code93Writer {
* @return 9 * @return 9
* @deprecated without replacement; intended as an internal-only method * @deprecated without replacement; intended as an internal-only method
*/ */
#[allow(dead_code)]
#[deprecated] #[deprecated]
fn appendPatternWithPatternStart( fn appendPatternWithPatternStart(
target: &mut [bool], target: &mut [bool],
pos: usize, pos: usize,
pattern: &[usize], pattern: &[usize],
startColor: bool, _startColor: bool,
) -> u32 { ) -> u32 {
let mut pos = pos; let mut pos = pos;
for bit in pattern { for bit in pattern {
@@ -219,7 +220,7 @@ impl Code93Writer {
mod Code93WriterTestCase { mod Code93WriterTestCase {
use crate::{ use crate::{
common::BitMatrixTestCase, common::BitMatrixTestCase,
oned::{Code93Writer, OneDimensionalCodeWriter}, oned::{Code93Writer},
BarcodeFormat, Writer, BarcodeFormat, Writer,
}; };

View File

@@ -67,7 +67,7 @@ impl OneDimensionalCodeWriter for EAN13Writer {
} }
} }
EAN13Writer::checkNumeric(&contents); EAN13Writer::checkNumeric(&contents)?;
let firstDigit = contents.chars().nth(0).unwrap().to_digit(10).unwrap() as usize; //, 10); let firstDigit = contents.chars().nth(0).unwrap().to_digit(10).unwrap() as usize; //, 10);
let parities = EAN13Reader::FIRST_DIGIT_ENCODINGS[firstDigit]; let parities = EAN13Reader::FIRST_DIGIT_ENCODINGS[firstDigit];

View File

@@ -22,7 +22,7 @@ use crate::Reader;
use super::EAN13Reader; use super::EAN13Reader;
use super::EAN8Reader; use super::EAN8Reader;
use super::StandIn; use super::STAND_IN;
use super::UPCAReader; use super::UPCAReader;
use super::UPCEReader; use super::UPCEReader;
use super::{OneDReader, UPCEANReader}; use super::{OneDReader, UPCEANReader};
@@ -124,7 +124,7 @@ impl OneDReader for MultiFormatUPCEANReader {
hints: &crate::DecodingHintDictionary, hints: &crate::DecodingHintDictionary,
) -> Result<crate::RXingResult, crate::Exceptions> { ) -> Result<crate::RXingResult, crate::Exceptions> {
// Compute this location once and reuse it on multiple implementations // Compute this location once and reuse it on multiple implementations
let startGuardPattern = StandIn.findStartGuardPattern(row)?; let startGuardPattern = STAND_IN.findStartGuardPattern(row)?;
for reader in &self.0 { for reader in &self.0 {
// for (UPCEANReader reader : readers) { // for (UPCEANReader reader : readers) {
let try_result = let try_result =

View File

@@ -202,7 +202,7 @@ impl Writer for L {
} }
} }
impl OneDimensionalCodeWriter for L { impl OneDimensionalCodeWriter for L {
fn encode_oned(&self, contents: &str) -> Result<Vec<bool>, Exceptions> { fn encode_oned(&self, _contents: &str) -> Result<Vec<bool>, Exceptions> {
todo!() todo!()
} }
} }

View File

@@ -78,13 +78,13 @@ fn checkWeight(weight: u32) -> u32 {
mod AI013103DecoderTest { mod AI013103DecoderTest {
use crate::oned::rss::expanded::decoders::abstract_decoder_test_utils::*; use crate::oned::rss::expanded::decoders::abstract_decoder_test_utils::*;
const header: &str = "..X.."; const HEADER: &str = "..X..";
#[test] #[test]
fn test0131031() { fn test0131031() {
let data = format!( let data = format!(
"{}{}{}", "{}{}{}",
header, compressedGtin900123456798908, compressed15bitWeight1750 HEADER, compressedGtin900123456798908, compressed15bitWeight1750
); );
let expected = "(01)90012345678908(3103)001750"; let expected = "(01)90012345678908(3103)001750";
assertCorrectBinaryString(&data, expected); assertCorrectBinaryString(&data, expected);
@@ -94,7 +94,7 @@ mod AI013103DecoderTest {
fn test0131032() { fn test0131032() {
let data = format!( let data = format!(
"{}{}{}", "{}{}{}",
header, compressedGtin900000000000008, compressed15bitWeight0 HEADER, compressedGtin900000000000008, compressed15bitWeight0
); );
let expected = "(01)90000000000003(3103)000000"; let expected = "(01)90000000000003(3103)000000";
assertCorrectBinaryString(&data, expected); assertCorrectBinaryString(&data, expected);
@@ -105,7 +105,7 @@ mod AI013103DecoderTest {
fn test013103invalid() { fn test013103invalid() {
let data = format!( let data = format!(
"{}{}{}..", "{}{}{}..",
header, compressedGtin900123456798908, compressed15bitWeight1750 HEADER, compressedGtin900123456798908, compressed15bitWeight1750
); );
assertCorrectBinaryString(&data, ""); assertCorrectBinaryString(&data, "");
} }

View File

@@ -30,13 +30,13 @@ use super::abstract_decoder_test_utils::*;
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
*/ */
const header: &str = "..X.X"; const HEADER: &str = "..X.X";
#[test] #[test]
fn test0132021() { fn test0132021() {
let data = format!( let data = format!(
"{}{}{}", "{}{}{}",
header, compressedGtin900123456798908, compressed15bitWeight1750 HEADER, compressedGtin900123456798908, compressed15bitWeight1750
); );
let expected = "(01)90012345678908(3202)001750"; let expected = "(01)90012345678908(3202)001750";
@@ -47,7 +47,7 @@ fn test0132021() {
fn test0132031() { fn test0132031() {
let data = format!( let data = format!(
"{}{}{}", "{}{}{}",
header, compressedGtin900123456798908, compressed15bitWeight11750 HEADER, compressedGtin900123456798908, compressed15bitWeight11750
); );
let expected = "(01)90012345678908(3203)001750"; let expected = "(01)90012345678908(3203)001750";

View File

@@ -139,20 +139,20 @@ impl<'a> AI013x0x1xDecoder<'_> {
mod AI013X0X1XDecoderTest { mod AI013X0X1XDecoderTest {
use crate::oned::rss::expanded::decoders::abstract_decoder_test_utils::*; use crate::oned::rss::expanded::decoders::abstract_decoder_test_utils::*;
const header310x11: &str = "..XXX..."; const HEADER310X11: &str = "..XXX...";
const header320x11: &str = "..XXX..X"; const HEADER320X11: &str = "..XXX..X";
const header310x13: &str = "..XXX.X."; const HEADER310X13: &str = "..XXX.X.";
const header320x13: &str = "..XXX.XX"; const HEADER320X13: &str = "..XXX.XX";
const header310x15: &str = "..XXXX.."; const HEADER310X15: &str = "..XXXX..";
const header320x15: &str = "..XXXX.X"; const HEADER320X15: &str = "..XXXX.X";
const header310x17: &str = "..XXXXX."; const HEADER310X17: &str = "..XXXXX.";
const header320x17: &str = "..XXXXXX"; const HEADER320X17: &str = "..XXXXXX";
#[test] #[test]
fn test01310X1XendDate() { fn test01310X1XendDate() {
let data = format!( let data = format!(
"{}{}{}{}", "{}{}{}{}",
header310x11, HEADER310X11,
compressedGtin900123456798908, compressedGtin900123456798908,
compressed20bitWeight1750, compressed20bitWeight1750,
compressedDateEnd compressedDateEnd
@@ -166,7 +166,7 @@ mod AI013X0X1XDecoderTest {
fn test01310X111() { fn test01310X111() {
let data = format!( let data = format!(
"{}{}{}{}", "{}{}{}{}",
header310x11, HEADER310X11,
compressedGtin900123456798908, compressedGtin900123456798908,
compressed20bitWeight1750, compressed20bitWeight1750,
compressedDateMarch12th2010 compressedDateMarch12th2010
@@ -180,7 +180,7 @@ mod AI013X0X1XDecoderTest {
fn test01320X111() { fn test01320X111() {
let data = format!( let data = format!(
"{}{}{}{}", "{}{}{}{}",
header320x11, HEADER320X11,
compressedGtin900123456798908, compressedGtin900123456798908,
compressed20bitWeight1750, compressed20bitWeight1750,
compressedDateMarch12th2010 compressedDateMarch12th2010
@@ -194,7 +194,7 @@ mod AI013X0X1XDecoderTest {
fn test01310X131() { fn test01310X131() {
let data = format!( let data = format!(
"{}{}{}{}", "{}{}{}{}",
header310x13, HEADER310X13,
compressedGtin900123456798908, compressedGtin900123456798908,
compressed20bitWeight1750, compressed20bitWeight1750,
compressedDateMarch12th2010 compressedDateMarch12th2010
@@ -208,7 +208,7 @@ mod AI013X0X1XDecoderTest {
fn test01320X131() { fn test01320X131() {
let data = format!( let data = format!(
"{}{}{}{}", "{}{}{}{}",
header320x13, HEADER320X13,
compressedGtin900123456798908, compressedGtin900123456798908,
compressed20bitWeight1750, compressed20bitWeight1750,
compressedDateMarch12th2010 compressedDateMarch12th2010
@@ -222,7 +222,7 @@ mod AI013X0X1XDecoderTest {
fn test01310X151() { fn test01310X151() {
let data = format!( let data = format!(
"{}{}{}{}", "{}{}{}{}",
header310x15, HEADER310X15,
compressedGtin900123456798908, compressedGtin900123456798908,
compressed20bitWeight1750, compressed20bitWeight1750,
compressedDateMarch12th2010 compressedDateMarch12th2010
@@ -236,7 +236,7 @@ mod AI013X0X1XDecoderTest {
fn test01320X151() { fn test01320X151() {
let data = format!( let data = format!(
"{}{}{}{}", "{}{}{}{}",
header320x15, HEADER320X15,
compressedGtin900123456798908, compressedGtin900123456798908,
compressed20bitWeight1750, compressed20bitWeight1750,
compressedDateMarch12th2010 compressedDateMarch12th2010
@@ -250,7 +250,7 @@ mod AI013X0X1XDecoderTest {
fn test01310X171() { fn test01310X171() {
let data = format!( let data = format!(
"{}{}{}{}", "{}{}{}{}",
header310x17, HEADER310X17,
compressedGtin900123456798908, compressedGtin900123456798908,
compressed20bitWeight1750, compressed20bitWeight1750,
compressedDateMarch12th2010 compressedDateMarch12th2010
@@ -264,7 +264,7 @@ mod AI013X0X1XDecoderTest {
fn test01320X171() { fn test01320X171() {
let data = format!( let data = format!(
"{}{}{}{}", "{}{}{}{}",
header320x17, HEADER320X17,
compressedGtin900123456798908, compressedGtin900123456798908,
compressed20bitWeight1750, compressed20bitWeight1750,
compressedDateMarch12th2010 compressedDateMarch12th2010

View File

@@ -48,7 +48,7 @@ impl DecodedNumeric {
pub fn new(newPosition: usize, firstDigit: u32, secondDigit: u32) -> Result<Self, Exceptions> { pub fn new(newPosition: usize, firstDigit: u32, secondDigit: u32) -> Result<Self, Exceptions> {
// super(newPosition); // super(newPosition);
if firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10 { if /*firstDigit < 0 ||*/ firstDigit > 10 || /*secondDigit < 0 ||*/ secondDigit > 10 {
return Err(Exceptions::FormatException( return Err(Exceptions::FormatException(
".getFormatInstance();".to_owned(), ".getFormatInstance();".to_owned(),
)); ));

View File

@@ -21,7 +21,7 @@ use crate::{
RXingResultMetadataValue, RXingResultPoint, RXingResultMetadataValue, RXingResultPoint,
}; };
use super::{upc_ean_reader, StandIn, UPCEANReader}; use super::{upc_ean_reader, STAND_IN, UPCEANReader};
/** /**
* @see UPCEANExtension5Support * @see UPCEANExtension5Support
@@ -88,7 +88,7 @@ impl UPCEANExtension2Support {
let mut x = 0; let mut x = 0;
while x < 2 && rowOffset < end { while x < 2 && rowOffset < end {
// for (int x = 0; x < 2 && rowOffset < end; x++) { // for (int x = 0; x < 2 && rowOffset < end; x++) {
let bestMatch = StandIn.decodeDigit( let bestMatch = STAND_IN.decodeDigit(
row, row,
&mut counters, &mut counters,
rowOffset, rowOffset,

View File

@@ -21,7 +21,7 @@ use crate::{
RXingResultMetadataValue, RXingResultPoint, RXingResultMetadataValue, RXingResultPoint,
}; };
use super::{upc_ean_reader, StandIn, UPCEANReader}; use super::{upc_ean_reader, STAND_IN, UPCEANReader};
/** /**
* @see UPCEANExtension2Support * @see UPCEANExtension2Support
@@ -90,7 +90,7 @@ impl UPCEANExtension5Support {
let mut x = 0; let mut x = 0;
while x < 5 && rowOffset < end { while x < 5 && rowOffset < end {
// for (int x = 0; x < 5 && rowOffset < end; x++) { // for (int x = 0; x < 5 && rowOffset < end; x++) {
let bestMatch = StandIn.decodeDigit( let bestMatch = STAND_IN.decodeDigit(
row, row,
&mut counters, &mut counters,
rowOffset, rowOffset,

View File

@@ -16,7 +16,7 @@
use crate::{common::BitArray, Exceptions, RXingResult}; use crate::{common::BitArray, Exceptions, RXingResult};
use super::{StandIn, UPCEANExtension2Support, UPCEANExtension5Support, UPCEANReader}; use super::{STAND_IN, UPCEANExtension2Support, UPCEANExtension5Support, UPCEANReader};
pub struct UPCEANExtensionSupport { pub struct UPCEANExtensionSupport {
twoSupport: UPCEANExtension2Support, twoSupport: UPCEANExtension2Support,
@@ -41,7 +41,7 @@ impl UPCEANExtensionSupport {
rowOffset: usize, rowOffset: usize,
) -> Result<RXingResult, Exceptions> { ) -> Result<RXingResult, Exceptions> {
let extensionStartRange = let extensionStartRange =
StandIn.findGuardPattern(row, rowOffset, false, &Self::EXTENSION_START_PATTERN)?; STAND_IN.findGuardPattern(row, rowOffset, false, &Self::EXTENSION_START_PATTERN)?;
if let Ok(res_1) = self if let Ok(res_1) = self
.fiveSupport .fiveSupport
.decodeRow(rowNumber, row, &extensionStartRange) .decodeRow(rowNumber, row, &extensionStartRange)

View File

@@ -245,7 +245,7 @@ pub trait UPCEANReader: OneDReader {
Ok(()) Ok(())
}; };
let try_result = attempt(); let _try_result = attempt();
// if let Err(Exceptions::ReaderException(_)) = try_result { // if let Err(Exceptions::ReaderException(_)) = try_result {
// } else if try_result.is_err() { // } else if try_result.is_err() {
// return Err(try_result.err().unwrap()); // return Err(try_result.err().unwrap());
@@ -564,4 +564,4 @@ impl Reader for StandInStruct {
} }
} }
pub(crate) const StandIn: StandInStruct = StandInStruct {}; pub(crate) const STAND_IN: StandInStruct = StandInStruct {};

View File

@@ -19,7 +19,7 @@ use std::{fmt::Display, rc::Rc};
use crate::pdf417::pdf_417_common; use crate::pdf417::pdf_417_common;
use super::{ use super::{
BarcodeMetadata, BoundingBox, Codeword, DetectionRXingResultColumn, BarcodeMetadata, BoundingBox, Codeword,
DetectionRXingResultColumnTrait, DetectionRXingResultRowIndicatorColumn, DetectionRXingResultColumnTrait, DetectionRXingResultRowIndicatorColumn,
}; };
@@ -41,7 +41,7 @@ impl DetectionRXingResult {
boundingBox: Rc<BoundingBox>, boundingBox: Rc<BoundingBox>,
) -> DetectionRXingResult { ) -> DetectionRXingResult {
let mut columns = Vec::new(); let mut columns = Vec::new();
for i in 0..(barcodeMetadata.getColumnCount() as usize + 2) { for _i in 0..(barcodeMetadata.getColumnCount() as usize + 2) {
columns.push(None); columns.push(None);
} }
DetectionRXingResult { DetectionRXingResult {

View File

@@ -14,12 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
use std::fmt::Display;
use crate::{pdf417::pdf_417_common, ResultPoint}; use crate::{pdf417::pdf_417_common, ResultPoint};
use super::{ use super::{
BarcodeMetadata, BarcodeValue, BoundingBox, Codeword, DetectionRXingResultColumn, BarcodeMetadata, BarcodeValue, Codeword, DetectionRXingResultColumn,
DetectionRXingResultColumnTrait, DetectionRXingResultColumnTrait,
}; };

View File

@@ -30,6 +30,7 @@ pub fn corrupt(received: &mut [u32], howMany: u32, random: &mut rand::rngs::Thre
} }
} }
#[allow(dead_code)]
pub fn erase(received: &mut [u32], howMany: u32, random: &mut rand::rngs::ThreadRng) -> Vec<u32> { pub fn erase(received: &mut [u32], howMany: u32, random: &mut rand::rngs::ThreadRng) -> Vec<u32> {
let mut erased = vec![false; received.len()]; //BitSet::new(received.len()); let mut erased = vec![false; received.len()]; //BitSet::new(received.len());
let mut erasures = vec![0_u32; howMany as usize]; let mut erasures = vec![0_u32; howMany as usize];

View File

@@ -27,7 +27,7 @@ use lazy_static::lazy_static;
lazy_static! { lazy_static! {
// static ref PDF417_GF : Rc<&ModulusGF> = Rc::new(&ModulusGF::new(NUMBER_OF_CODEWORDS, 3)); // static ref PDF417_GF : Rc<&ModulusGF> = Rc::new(&ModulusGF::new(NUMBER_OF_CODEWORDS, 3));
static ref fld_interior : ModulusGF = ModulusGF::new(NUMBER_OF_CODEWORDS, 3); static ref FLD_INTERIOR : ModulusGF = ModulusGF::new(NUMBER_OF_CODEWORDS, 3);
} }
/** /**
@@ -52,7 +52,7 @@ pub fn decode<'a>(
numECCodewords: u32, numECCodewords: u32,
erasures: &mut [u32], erasures: &mut [u32],
) -> Result<usize, Exceptions> { ) -> Result<usize, Exceptions> {
let field: Rc<&'static ModulusGF> = Rc::new(&fld_interior); let field: Rc<&'static ModulusGF> = Rc::new(&FLD_INTERIOR);
let poly = ModulusPoly::new(field.clone(), received.to_vec())?; let poly = ModulusPoly::new(field.clone(), received.to_vec())?;
let mut S = vec![0u32; numECCodewords as usize]; let mut S = vec![0u32; numECCodewords as usize];
let mut error = false; let mut error = false;

View File

@@ -16,7 +16,7 @@
use rand::Rng; use rand::Rng;
use crate::{datamatrix::encoder::error_correction, Exceptions}; use crate::{ Exceptions};
use super::{ use super::{
abstract_error_correction_test_case::{corrupt, getRandom}, abstract_error_correction_test_case::{corrupt, getRandom},
@@ -56,7 +56,7 @@ fn testNoError() {
#[test] #[test]
fn testExplicitError() { fn testExplicitError() {
let mut random = getRandom();
for i in 0..PDF417_TEST_WITH_EC.len() { for i in 0..PDF417_TEST_WITH_EC.len() {
// for (int i = 0; i < PDF417_TEST_WITH_EC.length; i++) { // for (int i = 0; i < PDF417_TEST_WITH_EC.length; i++) {
let mut received = PDF417_TEST_WITH_EC.clone(); let mut received = PDF417_TEST_WITH_EC.clone();

View File

@@ -16,12 +16,8 @@
//public static final ModulusGF PDF417_GF = new ModulusGF(PDF417Common.NUMBER_OF_CODEWORDS, 3); //public static final ModulusGF PDF417_GF = new ModulusGF(PDF417Common.NUMBER_OF_CODEWORDS, 3);
use std::rc::Rc;
use crate::Exceptions; use crate::Exceptions;
use super::ModulusPoly;
/** /**
* <p>A field based on powers of a generator integer, modulo some modulus.</p> * <p>A field based on powers of a generator integer, modulo some modulus.</p>
* *

View File

@@ -461,7 +461,7 @@ fn encodeDecodeWithAll(
fn getEndIndex(length: u32, chars: &[char]) -> u32 { fn getEndIndex(length: u32, chars: &[char]) -> u32 {
let decimalLength: f64 = (chars.len() as f64).log10(); //Math.log10(chars.length); let decimalLength: f64 = (chars.len() as f64).log10(); //Math.log10(chars.length);
10_f64.powf((decimalLength * length as f64)).ceil() as u32 10_f64.powf(decimalLength * length as f64).ceil() as u32
// (decimalLength*length as f64).powi(10).ceil() as u32 // (decimalLength*length as f64).powi(10).ceil() as u32
// (decimalLength*length as f64).powi(10).ceil() as u32 // (decimalLength*length as f64).powi(10).ceil() as u32
// Math.ceil(Math.pow(10, decimalLength * length)) // Math.ceil(Math.pow(10, decimalLength * length))

View File

@@ -32,14 +32,14 @@ fn testMask0() {
#[test] #[test]
fn testMask1() { fn testMask1() {
testMaskAcrossDimensions(DataMask::DATA_MASK_001, |i, j| i % 2 == 0); testMaskAcrossDimensions(DataMask::DATA_MASK_001, |i, _j| i % 2 == 0);
testMaskAcrossDimensionsU8(1, |i, j| i % 2 == 0); testMaskAcrossDimensionsU8(1, |i, _j| i % 2 == 0);
} }
#[test] #[test]
fn testMask2() { fn testMask2() {
testMaskAcrossDimensions(DataMask::DATA_MASK_010, |i, j| j % 3 == 0); testMaskAcrossDimensions(DataMask::DATA_MASK_010, |_i, j| j % 3 == 0);
testMaskAcrossDimensionsU8(2, |i, j| j % 3 == 0); testMaskAcrossDimensionsU8(2, |_i, j| j % 3 == 0);
} }
#[test] #[test]

View File

@@ -10,7 +10,7 @@ mod qr_code_decoder_meta_data;
mod version; mod version;
#[cfg(test)] #[cfg(test)]
mod DataMaskTestCase; mod data_mask_testcase;
#[cfg(test)] #[cfg(test)]
mod DecodedBitStreamParserTestCase; mod DecodedBitStreamParserTestCase;
#[cfg(test)] #[cfg(test)]

View File

@@ -40,6 +40,7 @@ fn test_encode_decode(value: &str) {
} }
// Zooms a bit matrix so that each bit is factor x factor // Zooms a bit matrix so that each bit is factor x factor
#[allow(dead_code)]
fn make_larger(input: &BitMatrix, factor: u32) -> BitMatrix { fn make_larger(input: &BitMatrix, factor: u32) -> BitMatrix {
let width = input.getWidth(); let width = input.getWidth();
let mut output = BitMatrix::with_single_dimension(width * factor); let mut output = BitMatrix::with_single_dimension(width * factor);

View File

@@ -15,4 +15,4 @@ pub use finder_pattern_info::*;
pub use qrcode_detector_result::*; pub use qrcode_detector_result::*;
#[cfg(test)] #[cfg(test)]
mod DetectorTest; mod cetector_test;

View File

@@ -128,7 +128,7 @@ fn testXOR() {
v1.appendBits(0x5555aaaa, 32).expect("append"); v1.appendBits(0x5555aaaa, 32).expect("append");
let mut v2 = BitArray::new(); let mut v2 = BitArray::new();
v2.appendBits(0xaaaa5555, 32).expect("append"); v2.appendBits(0xaaaa5555, 32).expect("append");
v1.xor(&v2); v1.xor(&v2).expect("xor");
assert_eq!(0xffffffff, getUnsignedInt(&v1)); assert_eq!(0xffffffff, getUnsignedInt(&v1));
} }
@@ -137,8 +137,8 @@ fn testXOR2() {
let mut v1 = BitArray::new(); let mut v1 = BitArray::new();
v1.appendBits(0x2a, 7).expect("append"); // 010 1010 v1.appendBits(0x2a, 7).expect("append"); // 010 1010
let mut v2 = BitArray::new(); let mut v2 = BitArray::new();
v2.appendBits(0x55, 7); // 101 0101 v2.appendBits(0x55, 7).expect("append"); // 101 0101
v1.xor(&v2); v1.xor(&v2).expect("xor");
assert_eq!(0xfe000000, getUnsignedInt(&v1)); // 1111 1110 assert_eq!(0xfe000000, getUnsignedInt(&v1)); // 1111 1110
} }

View File

@@ -13,25 +13,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/**
// package com.google.zxing.qrcode.encoder; * @author satorux@google.com (Satoru Takabayashi) - creator
* @author dswitkin@google.com (Daniel Switkin) - ported from C++
// import com.google.zxing.EncodeHintType; */
// import com.google.zxing.WriterException;
// import com.google.zxing.common.BitArray;
// import com.google.zxing.common.StringUtils;
// import com.google.zxing.common.CharacterSetECI;
// import com.google.zxing.common.reedsolomon.GenericGF;
// import com.google.zxing.common.reedsolomon.ReedSolomonEncoder;
// import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
// import com.google.zxing.qrcode.decoder.Mode;
// import com.google.zxing.qrcode.decoder.Version;
// import java.nio.charset.Charset;
// import java.nio.charset.StandardCharsets;
// import java.util.ArrayList;
// import java.util.Collection;
// import java.util.Map;
use std::collections::HashMap; use std::collections::HashMap;
@@ -51,11 +36,6 @@ use crate::{
use super::{mask_util, matrix_util, BlockPair, ByteMatrix, MinimalEncoder, QRCode}; use super::{mask_util, matrix_util, BlockPair, ByteMatrix, MinimalEncoder, QRCode};
/**
* @author satorux@google.com (Satoru Takabayashi) - creator
* @author dswitkin@google.com (Daniel Switkin) - ported from C++
*/
lazy_static! { lazy_static! {
static ref SHIFT_JIS_CHARSET: EncodingRef = static ref SHIFT_JIS_CHARSET: EncodingRef =
encoding::label::encoding_from_whatwg_label("SJIS").unwrap(); encoding::label::encoding_from_whatwg_label("SJIS").unwrap();

View File

@@ -245,7 +245,7 @@ fn testBuildMatrix() {
let mut bits = BitArray::new(); let mut bits = BitArray::new();
for c in bytes { for c in bytes {
// for (char c: bytes) { // for (char c: bytes) {
bits.appendBits(c, 8); bits.appendBits(c, 8).expect("append");
} }
let mut matrix = ByteMatrix::new(21, 21); let mut matrix = ByteMatrix::new(21, 21);
matrix_util::buildMatrix( matrix_util::buildMatrix(

View File

@@ -616,8 +616,8 @@ pub struct Edge {
characterLength: u32, characterLength: u32,
previous: Option<Rc<Edge>>, previous: Option<Rc<Edge>>,
cachedTotalSize: u32, cachedTotalSize: u32,
encoders: ECIEncoderSet, _encoders: ECIEncoderSet,
stringToEncode: Vec<String>, _stringToEncode: Vec<String>,
} }
impl Edge { impl Edge {
pub fn new( pub fn new(
@@ -641,7 +641,7 @@ impl Edge {
charsetEncoderIndex: nci, charsetEncoderIndex: nci,
characterLength, characterLength,
previous: previous.clone(), previous: previous.clone(),
stringToEncode: stringToEncode.clone(), _stringToEncode: stringToEncode.clone(),
cachedTotalSize: { cachedTotalSize: {
let mut size = if previous.is_some() { let mut size = if previous.is_some() {
previous.as_ref().unwrap().cachedTotalSize previous.as_ref().unwrap().cachedTotalSize
@@ -713,7 +713,7 @@ impl Edge {
// } // }
size size
}, },
encoders, _encoders : encoders,
} }
// this.mode = mode; // this.mode = mode;
// this.fromPosition = fromPosition; // this.fromPosition = fromPosition;

View File

@@ -12,12 +12,12 @@ pub use minimal_encoder::*;
pub use qr_code::*; pub use qr_code::*;
#[cfg(test)] #[cfg(test)]
mod BitVectorTestCase; mod bit_vector_testcase;
#[cfg(test)] #[cfg(test)]
mod EncoderTestCase; mod EncoderTestCase;
#[cfg(test)] #[cfg(test)]
mod MaskUtilTestCase; mod MaskUtilTestCase;
#[cfg(test)] #[cfg(test)]
mod MatrixUtilTestCase; mod matrix_util_testcase;
#[cfg(test)] #[cfg(test)]
mod QRCodeTestCase; mod QRCodeTestCase;

View File

@@ -16,7 +16,7 @@
//package com.google.zxing; //package com.google.zxing;
use std::{any::Any, rc::Rc}; use std::{ rc::Rc};
use crate::pdf417::PDF417RXingResultMetadata; use crate::pdf417::PDF417RXingResultMetadata;

View File

@@ -1,4 +1,4 @@
use rxing::{qrcode::QRCodeReader, BarcodeFormat, MultiFormatReader}; use rxing::{MultiFormatReader};
mod common; mod common;