mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
many warnings cleaned up
This commit is contained in:
@@ -9,6 +9,7 @@ lazy_static! {
|
||||
static ref DOTX: Regex = Regex::new("[^.X]").unwrap();
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn toBitArray(bits: &str) -> BitArray {
|
||||
let mut ba_in = BitArray::new();
|
||||
let str = DOTX.replace_all(bits, "");
|
||||
@@ -20,6 +21,7 @@ pub fn toBitArray(bits: &str) -> BitArray {
|
||||
ba_in
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn toBooleanArray(bitArray: &BitArray) -> Vec<bool> {
|
||||
let mut result = vec![false; bitArray.getSize()];
|
||||
for i in 0..result.len() {
|
||||
@@ -29,6 +31,7 @@ pub fn toBooleanArray(bitArray: &BitArray) -> Vec<bool> {
|
||||
result
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn stripSpace(s: &str) -> String {
|
||||
SPACES.replace_all(s, "").to_string()
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ use std::collections::HashMap;
|
||||
use crate::BarcodeFormat;
|
||||
|
||||
use super::{
|
||||
ExpandedProductParsedRXingResult, ExpandedProductParsedResult, ParsedClientResult, ResultParser,
|
||||
ExpandedProductParsedRXingResult, ParsedClientResult, ResultParser,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -70,7 +70,7 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<super::ParsedClientR
|
||||
// is 'true' or 'false':
|
||||
let mut hidden = 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)
|
||||
{
|
||||
// If PH2 was specified separately, or if the value is clearly boolean, interpret it as 'hidden'
|
||||
|
||||
@@ -269,7 +269,7 @@ fn test_parse_boolean() {
|
||||
fullMatrix.setRegion(0, 0, 3, 3).expect("must set");
|
||||
let mut centerMatrix = BitMatrix::new(3, 3).unwrap();
|
||||
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];
|
||||
// boolean[][] matrix = new boolean[3][3];
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::collections::HashMap;
|
||||
use crate::{
|
||||
common::{BitMatrix, DetectorRXingResult},
|
||||
BarcodeFormat, DecodeHintType, Exceptions, RXingResult, RXingResultMetadataType,
|
||||
RXingResultMetadataValue, RXingResultPoint, Reader,
|
||||
RXingResultMetadataValue, Reader,
|
||||
};
|
||||
|
||||
use super::{decoder::Decoder, detector::Detector};
|
||||
@@ -27,7 +27,7 @@ use super::{decoder::Decoder, detector::Detector};
|
||||
use 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();
|
||||
if hints.contains_key(&DecodeHintType::PURE_BARCODE) {
|
||||
let bits = self.extractPureBits(image.getBlackMatrix())?;
|
||||
decoderRXingResult = decoder.decode(&bits)?;
|
||||
decoderRXingResult = DECODER.decode(&bits)?;
|
||||
points.clear();
|
||||
} else {
|
||||
let detectorRXingResult = Detector::new(image.getBlackMatrix().clone())?.detect()?;
|
||||
decoderRXingResult = decoder.decode(detectorRXingResult.getBits())?;
|
||||
decoderRXingResult = DECODER.decode(detectorRXingResult.getBits())?;
|
||||
points = detectorRXingResult.getPoints().clone();
|
||||
}
|
||||
let mut result = RXingResult::new(
|
||||
|
||||
@@ -589,7 +589,7 @@ fn decodeEdifactSegment(
|
||||
// Read rest of byte, which should be 0, and stop
|
||||
let bitsLeft = 8 - bits.getBitOffset();
|
||||
if bitsLeft != 8 {
|
||||
bits.readBits(bitsLeft);
|
||||
bits.readBits(bitsLeft)?;
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
@@ -633,9 +633,10 @@ fn decodeBase256Segment(
|
||||
}
|
||||
|
||||
// We're seeing NegativeArraySizeException errors from users.
|
||||
if count < 0 {
|
||||
return Err(Exceptions::FormatException("".to_owned()));
|
||||
}
|
||||
// but we shouldn't in rust because it's unsigned
|
||||
// if count < 0 {
|
||||
// return Err(Exceptions::FormatException("".to_owned()));
|
||||
// }
|
||||
|
||||
let mut bytes = vec![0u8; count as usize];
|
||||
for i in 0..count as usize {
|
||||
|
||||
@@ -49,7 +49,7 @@ impl Encoder for X12Encoder {
|
||||
}
|
||||
}
|
||||
}
|
||||
Self::handleEOD(context, &mut buffer);
|
||||
Self::handleEOD(context, &mut buffer)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ impl X12Encoder {
|
||||
} else if c >= 'A' && c <= 'Z' {
|
||||
sb.push((c as u8 - 65 + 14) as char);
|
||||
} else {
|
||||
high_level_encoder::illegalCharacter(c);
|
||||
high_level_encoder::illegalCharacter(c).expect("detect_illegal_character");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,10 +86,10 @@ pub trait LuminanceSource {
|
||||
*/
|
||||
fn crop(
|
||||
&self,
|
||||
left: usize,
|
||||
top: usize,
|
||||
width: usize,
|
||||
height: usize,
|
||||
_left: usize,
|
||||
_top: usize,
|
||||
_width: usize,
|
||||
_height: usize,
|
||||
) -> Result<Box<dyn LuminanceSource>, Exceptions> {
|
||||
return Err(Exceptions::UnsupportedOperationException(
|
||||
"This luminance source does not support cropping.".to_owned(),
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use std::{collections::HashSet, path::PathBuf, rc::Rc};
|
||||
|
||||
use crate::{
|
||||
common::HybridBinarizer, qrcode::QRCodeReader, BarcodeFormat, BinaryBitmap,
|
||||
common::HybridBinarizer, BarcodeFormat, BinaryBitmap,
|
||||
BufferedImageLuminanceSource, MultiFormatReader,
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, DetectorRXingResult},
|
||||
common::{BitMatrix},
|
||||
qrcode::detector::{Detector, QRCodeDetectorResult},
|
||||
DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::cmp::Ordering;
|
||||
use crate::{
|
||||
common::BitMatrix,
|
||||
qrcode::detector::{FinderPattern, FinderPatternFinder, FinderPatternInfo},
|
||||
result_point_utils, DecodeHintType, DecodingHintDictionary, Exceptions, RXingResultPoint,
|
||||
result_point_utils, DecodeHintType, DecodingHintDictionary, Exceptions,
|
||||
RXingResultPointCallback,
|
||||
};
|
||||
|
||||
|
||||
@@ -169,7 +169,6 @@ impl Default for CodaBarWriter {
|
||||
mod CodaBarWriterTestCase {
|
||||
use crate::{
|
||||
common::{BitMatrix, BitMatrixTestCase},
|
||||
oned::OneDimensionalCodeWriter,
|
||||
BarcodeFormat, Writer,
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ use one_d_proc_derive::OneDWriter;
|
||||
|
||||
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_B: usize = 104;
|
||||
|
||||
@@ -44,7 +44,7 @@ use crate::{
|
||||
|
||||
use super::Code128Writer;
|
||||
lazy_static! {
|
||||
static ref writer: Code128Writer = Code128Writer::default();
|
||||
static ref WRITER: Code128Writer = Code128Writer::default();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -330,7 +330,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetABadCharacter() {
|
||||
EncodeHintType::FORCE_CODE_SET,
|
||||
EncodeHintValue::ForceCodeSet("A".to_string()),
|
||||
);
|
||||
writer
|
||||
WRITER
|
||||
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
|
||||
.expect("encode");
|
||||
}
|
||||
@@ -348,7 +348,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetBBadCharacter() {
|
||||
);
|
||||
// let hints = new EnumMap<>(EncodeHintType.class);
|
||||
// hints.put(EncodeHintType.FORCE_CODE_SET, "B");
|
||||
writer
|
||||
WRITER
|
||||
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
|
||||
.expect("encode");
|
||||
}
|
||||
@@ -366,7 +366,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetCBadCharactersNonNum() {
|
||||
);
|
||||
// let hints = new EnumMap<>(EncodeHintType.class);
|
||||
// hints.put(EncodeHintType.FORCE_CODE_SET, "C");
|
||||
writer
|
||||
WRITER
|
||||
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
|
||||
.expect("encode");
|
||||
}
|
||||
@@ -382,7 +382,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetCBadCharactersFncCode() {
|
||||
EncodeHintType::FORCE_CODE_SET,
|
||||
EncodeHintValue::ForceCodeSet("C".to_string()),
|
||||
);
|
||||
writer
|
||||
WRITER
|
||||
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
|
||||
.expect("encode");
|
||||
}
|
||||
@@ -398,7 +398,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetCWrongAmountOfDigits() {
|
||||
EncodeHintType::FORCE_CODE_SET,
|
||||
EncodeHintValue::ForceCodeSet("C".to_string()),
|
||||
);
|
||||
writer
|
||||
WRITER
|
||||
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
|
||||
.expect("encode");
|
||||
}
|
||||
@@ -429,7 +429,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetA() {
|
||||
EncodeHintType::FORCE_CODE_SET,
|
||||
EncodeHintValue::ForceCodeSet("A".to_string()),
|
||||
);
|
||||
let result = writer
|
||||
let result = WRITER
|
||||
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
|
||||
.expect("encode");
|
||||
|
||||
@@ -462,7 +462,7 @@ fn testEncodeWithForcedCodeSetFailureCodeSetB() {
|
||||
EncodeHintType::FORCE_CODE_SET,
|
||||
EncodeHintValue::ForceCodeSet("B".to_string()),
|
||||
);
|
||||
let result = writer
|
||||
let result = WRITER
|
||||
.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)
|
||||
.expect("encode");
|
||||
|
||||
@@ -481,7 +481,7 @@ fn encode(toEncode: &str, compact: bool, expectedLoopback: &str) -> Result<BitMa
|
||||
);
|
||||
}
|
||||
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() {
|
||||
let row = encRXingResult.getRow(0, BitArray::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 rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?;
|
||||
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 rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?;
|
||||
assert_eq!(rtRXingResult.getText(), actual);
|
||||
|
||||
@@ -95,12 +95,13 @@ impl Code93Writer {
|
||||
* @return 9
|
||||
* @deprecated without replacement; intended as an internal-only method
|
||||
*/
|
||||
#[allow(dead_code)]
|
||||
#[deprecated]
|
||||
fn appendPatternWithPatternStart(
|
||||
target: &mut [bool],
|
||||
pos: usize,
|
||||
pattern: &[usize],
|
||||
startColor: bool,
|
||||
_startColor: bool,
|
||||
) -> u32 {
|
||||
let mut pos = pos;
|
||||
for bit in pattern {
|
||||
@@ -219,7 +220,7 @@ impl Code93Writer {
|
||||
mod Code93WriterTestCase {
|
||||
use crate::{
|
||||
common::BitMatrixTestCase,
|
||||
oned::{Code93Writer, OneDimensionalCodeWriter},
|
||||
oned::{Code93Writer},
|
||||
BarcodeFormat, Writer,
|
||||
};
|
||||
|
||||
|
||||
@@ -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 parities = EAN13Reader::FIRST_DIGIT_ENCODINGS[firstDigit];
|
||||
|
||||
@@ -22,7 +22,7 @@ use crate::Reader;
|
||||
|
||||
use super::EAN13Reader;
|
||||
use super::EAN8Reader;
|
||||
use super::StandIn;
|
||||
use super::STAND_IN;
|
||||
use super::UPCAReader;
|
||||
use super::UPCEReader;
|
||||
use super::{OneDReader, UPCEANReader};
|
||||
@@ -124,7 +124,7 @@ impl OneDReader for MultiFormatUPCEANReader {
|
||||
hints: &crate::DecodingHintDictionary,
|
||||
) -> Result<crate::RXingResult, crate::Exceptions> {
|
||||
// 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 (UPCEANReader reader : readers) {
|
||||
let try_result =
|
||||
|
||||
@@ -202,7 +202,7 @@ impl Writer 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!()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,13 +78,13 @@ fn checkWeight(weight: u32) -> u32 {
|
||||
mod AI013103DecoderTest {
|
||||
use crate::oned::rss::expanded::decoders::abstract_decoder_test_utils::*;
|
||||
|
||||
const header: &str = "..X..";
|
||||
const HEADER: &str = "..X..";
|
||||
|
||||
#[test]
|
||||
fn test0131031() {
|
||||
let data = format!(
|
||||
"{}{}{}",
|
||||
header, compressedGtin900123456798908, compressed15bitWeight1750
|
||||
HEADER, compressedGtin900123456798908, compressed15bitWeight1750
|
||||
);
|
||||
let expected = "(01)90012345678908(3103)001750";
|
||||
assertCorrectBinaryString(&data, expected);
|
||||
@@ -94,7 +94,7 @@ mod AI013103DecoderTest {
|
||||
fn test0131032() {
|
||||
let data = format!(
|
||||
"{}{}{}",
|
||||
header, compressedGtin900000000000008, compressed15bitWeight0
|
||||
HEADER, compressedGtin900000000000008, compressed15bitWeight0
|
||||
);
|
||||
let expected = "(01)90000000000003(3103)000000";
|
||||
assertCorrectBinaryString(&data, expected);
|
||||
@@ -105,7 +105,7 @@ mod AI013103DecoderTest {
|
||||
fn test013103invalid() {
|
||||
let data = format!(
|
||||
"{}{}{}..",
|
||||
header, compressedGtin900123456798908, compressed15bitWeight1750
|
||||
HEADER, compressedGtin900123456798908, compressed15bitWeight1750
|
||||
);
|
||||
assertCorrectBinaryString(&data, "");
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ use super::abstract_decoder_test_utils::*;
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
|
||||
const header: &str = "..X.X";
|
||||
const HEADER: &str = "..X.X";
|
||||
|
||||
#[test]
|
||||
fn test0132021() {
|
||||
let data = format!(
|
||||
"{}{}{}",
|
||||
header, compressedGtin900123456798908, compressed15bitWeight1750
|
||||
HEADER, compressedGtin900123456798908, compressed15bitWeight1750
|
||||
);
|
||||
let expected = "(01)90012345678908(3202)001750";
|
||||
|
||||
@@ -47,7 +47,7 @@ fn test0132021() {
|
||||
fn test0132031() {
|
||||
let data = format!(
|
||||
"{}{}{}",
|
||||
header, compressedGtin900123456798908, compressed15bitWeight11750
|
||||
HEADER, compressedGtin900123456798908, compressed15bitWeight11750
|
||||
);
|
||||
let expected = "(01)90012345678908(3203)001750";
|
||||
|
||||
|
||||
@@ -139,20 +139,20 @@ impl<'a> AI013x0x1xDecoder<'_> {
|
||||
mod AI013X0X1XDecoderTest {
|
||||
use crate::oned::rss::expanded::decoders::abstract_decoder_test_utils::*;
|
||||
|
||||
const header310x11: &str = "..XXX...";
|
||||
const header320x11: &str = "..XXX..X";
|
||||
const header310x13: &str = "..XXX.X.";
|
||||
const header320x13: &str = "..XXX.XX";
|
||||
const header310x15: &str = "..XXXX..";
|
||||
const header320x15: &str = "..XXXX.X";
|
||||
const header310x17: &str = "..XXXXX.";
|
||||
const header320x17: &str = "..XXXXXX";
|
||||
const HEADER310X11: &str = "..XXX...";
|
||||
const HEADER320X11: &str = "..XXX..X";
|
||||
const HEADER310X13: &str = "..XXX.X.";
|
||||
const HEADER320X13: &str = "..XXX.XX";
|
||||
const HEADER310X15: &str = "..XXXX..";
|
||||
const HEADER320X15: &str = "..XXXX.X";
|
||||
const HEADER310X17: &str = "..XXXXX.";
|
||||
const HEADER320X17: &str = "..XXXXXX";
|
||||
|
||||
#[test]
|
||||
fn test01310X1XendDate() {
|
||||
let data = format!(
|
||||
"{}{}{}{}",
|
||||
header310x11,
|
||||
HEADER310X11,
|
||||
compressedGtin900123456798908,
|
||||
compressed20bitWeight1750,
|
||||
compressedDateEnd
|
||||
@@ -166,7 +166,7 @@ mod AI013X0X1XDecoderTest {
|
||||
fn test01310X111() {
|
||||
let data = format!(
|
||||
"{}{}{}{}",
|
||||
header310x11,
|
||||
HEADER310X11,
|
||||
compressedGtin900123456798908,
|
||||
compressed20bitWeight1750,
|
||||
compressedDateMarch12th2010
|
||||
@@ -180,7 +180,7 @@ mod AI013X0X1XDecoderTest {
|
||||
fn test01320X111() {
|
||||
let data = format!(
|
||||
"{}{}{}{}",
|
||||
header320x11,
|
||||
HEADER320X11,
|
||||
compressedGtin900123456798908,
|
||||
compressed20bitWeight1750,
|
||||
compressedDateMarch12th2010
|
||||
@@ -194,7 +194,7 @@ mod AI013X0X1XDecoderTest {
|
||||
fn test01310X131() {
|
||||
let data = format!(
|
||||
"{}{}{}{}",
|
||||
header310x13,
|
||||
HEADER310X13,
|
||||
compressedGtin900123456798908,
|
||||
compressed20bitWeight1750,
|
||||
compressedDateMarch12th2010
|
||||
@@ -208,7 +208,7 @@ mod AI013X0X1XDecoderTest {
|
||||
fn test01320X131() {
|
||||
let data = format!(
|
||||
"{}{}{}{}",
|
||||
header320x13,
|
||||
HEADER320X13,
|
||||
compressedGtin900123456798908,
|
||||
compressed20bitWeight1750,
|
||||
compressedDateMarch12th2010
|
||||
@@ -222,7 +222,7 @@ mod AI013X0X1XDecoderTest {
|
||||
fn test01310X151() {
|
||||
let data = format!(
|
||||
"{}{}{}{}",
|
||||
header310x15,
|
||||
HEADER310X15,
|
||||
compressedGtin900123456798908,
|
||||
compressed20bitWeight1750,
|
||||
compressedDateMarch12th2010
|
||||
@@ -236,7 +236,7 @@ mod AI013X0X1XDecoderTest {
|
||||
fn test01320X151() {
|
||||
let data = format!(
|
||||
"{}{}{}{}",
|
||||
header320x15,
|
||||
HEADER320X15,
|
||||
compressedGtin900123456798908,
|
||||
compressed20bitWeight1750,
|
||||
compressedDateMarch12th2010
|
||||
@@ -250,7 +250,7 @@ mod AI013X0X1XDecoderTest {
|
||||
fn test01310X171() {
|
||||
let data = format!(
|
||||
"{}{}{}{}",
|
||||
header310x17,
|
||||
HEADER310X17,
|
||||
compressedGtin900123456798908,
|
||||
compressed20bitWeight1750,
|
||||
compressedDateMarch12th2010
|
||||
@@ -264,7 +264,7 @@ mod AI013X0X1XDecoderTest {
|
||||
fn test01320X171() {
|
||||
let data = format!(
|
||||
"{}{}{}{}",
|
||||
header320x17,
|
||||
HEADER320X17,
|
||||
compressedGtin900123456798908,
|
||||
compressed20bitWeight1750,
|
||||
compressedDateMarch12th2010
|
||||
|
||||
@@ -48,7 +48,7 @@ impl DecodedNumeric {
|
||||
pub fn new(newPosition: usize, firstDigit: u32, secondDigit: u32) -> Result<Self, Exceptions> {
|
||||
// super(newPosition);
|
||||
|
||||
if firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10 {
|
||||
if /*firstDigit < 0 ||*/ firstDigit > 10 || /*secondDigit < 0 ||*/ secondDigit > 10 {
|
||||
return Err(Exceptions::FormatException(
|
||||
".getFormatInstance();".to_owned(),
|
||||
));
|
||||
|
||||
@@ -21,7 +21,7 @@ use crate::{
|
||||
RXingResultMetadataValue, RXingResultPoint,
|
||||
};
|
||||
|
||||
use super::{upc_ean_reader, StandIn, UPCEANReader};
|
||||
use super::{upc_ean_reader, STAND_IN, UPCEANReader};
|
||||
|
||||
/**
|
||||
* @see UPCEANExtension5Support
|
||||
@@ -88,7 +88,7 @@ impl UPCEANExtension2Support {
|
||||
let mut x = 0;
|
||||
while x < 2 && rowOffset < end {
|
||||
// for (int x = 0; x < 2 && rowOffset < end; x++) {
|
||||
let bestMatch = StandIn.decodeDigit(
|
||||
let bestMatch = STAND_IN.decodeDigit(
|
||||
row,
|
||||
&mut counters,
|
||||
rowOffset,
|
||||
|
||||
@@ -21,7 +21,7 @@ use crate::{
|
||||
RXingResultMetadataValue, RXingResultPoint,
|
||||
};
|
||||
|
||||
use super::{upc_ean_reader, StandIn, UPCEANReader};
|
||||
use super::{upc_ean_reader, STAND_IN, UPCEANReader};
|
||||
|
||||
/**
|
||||
* @see UPCEANExtension2Support
|
||||
@@ -90,7 +90,7 @@ impl UPCEANExtension5Support {
|
||||
let mut x = 0;
|
||||
while x < 5 && rowOffset < end {
|
||||
// for (int x = 0; x < 5 && rowOffset < end; x++) {
|
||||
let bestMatch = StandIn.decodeDigit(
|
||||
let bestMatch = STAND_IN.decodeDigit(
|
||||
row,
|
||||
&mut counters,
|
||||
rowOffset,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use crate::{common::BitArray, Exceptions, RXingResult};
|
||||
|
||||
use super::{StandIn, UPCEANExtension2Support, UPCEANExtension5Support, UPCEANReader};
|
||||
use super::{STAND_IN, UPCEANExtension2Support, UPCEANExtension5Support, UPCEANReader};
|
||||
|
||||
pub struct UPCEANExtensionSupport {
|
||||
twoSupport: UPCEANExtension2Support,
|
||||
@@ -41,7 +41,7 @@ impl UPCEANExtensionSupport {
|
||||
rowOffset: usize,
|
||||
) -> Result<RXingResult, Exceptions> {
|
||||
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
|
||||
.fiveSupport
|
||||
.decodeRow(rowNumber, row, &extensionStartRange)
|
||||
|
||||
@@ -245,7 +245,7 @@ pub trait UPCEANReader: OneDReader {
|
||||
Ok(())
|
||||
};
|
||||
|
||||
let try_result = attempt();
|
||||
let _try_result = attempt();
|
||||
// if let Err(Exceptions::ReaderException(_)) = try_result {
|
||||
// } else if try_result.is_err() {
|
||||
// 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 {};
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::{fmt::Display, rc::Rc};
|
||||
use crate::pdf417::pdf_417_common;
|
||||
|
||||
use super::{
|
||||
BarcodeMetadata, BoundingBox, Codeword, DetectionRXingResultColumn,
|
||||
BarcodeMetadata, BoundingBox, Codeword,
|
||||
DetectionRXingResultColumnTrait, DetectionRXingResultRowIndicatorColumn,
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ impl DetectionRXingResult {
|
||||
boundingBox: Rc<BoundingBox>,
|
||||
) -> DetectionRXingResult {
|
||||
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);
|
||||
}
|
||||
DetectionRXingResult {
|
||||
|
||||
@@ -14,12 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
use crate::{pdf417::pdf_417_common, ResultPoint};
|
||||
|
||||
use super::{
|
||||
BarcodeMetadata, BarcodeValue, BoundingBox, Codeword, DetectionRXingResultColumn,
|
||||
BarcodeMetadata, BarcodeValue, Codeword, DetectionRXingResultColumn,
|
||||
DetectionRXingResultColumnTrait,
|
||||
};
|
||||
|
||||
|
||||
@@ -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> {
|
||||
let mut erased = vec![false; received.len()]; //BitSet::new(received.len());
|
||||
let mut erasures = vec![0_u32; howMany as usize];
|
||||
|
||||
@@ -27,7 +27,7 @@ use lazy_static::lazy_static;
|
||||
|
||||
lazy_static! {
|
||||
// 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,
|
||||
erasures: &mut [u32],
|
||||
) -> 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 mut S = vec![0u32; numECCodewords as usize];
|
||||
let mut error = false;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use rand::Rng;
|
||||
|
||||
use crate::{datamatrix::encoder::error_correction, Exceptions};
|
||||
use crate::{ Exceptions};
|
||||
|
||||
use super::{
|
||||
abstract_error_correction_test_case::{corrupt, getRandom},
|
||||
@@ -56,7 +56,7 @@ fn testNoError() {
|
||||
|
||||
#[test]
|
||||
fn testExplicitError() {
|
||||
let mut random = getRandom();
|
||||
|
||||
for i in 0..PDF417_TEST_WITH_EC.len() {
|
||||
// for (int i = 0; i < PDF417_TEST_WITH_EC.length; i++) {
|
||||
let mut received = PDF417_TEST_WITH_EC.clone();
|
||||
|
||||
@@ -16,12 +16,8 @@
|
||||
|
||||
//public static final ModulusGF PDF417_GF = new ModulusGF(PDF417Common.NUMBER_OF_CODEWORDS, 3);
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::Exceptions;
|
||||
|
||||
use super::ModulusPoly;
|
||||
|
||||
/**
|
||||
* <p>A field based on powers of a generator integer, modulo some modulus.</p>
|
||||
*
|
||||
|
||||
@@ -461,7 +461,7 @@ fn encodeDecodeWithAll(
|
||||
|
||||
fn getEndIndex(length: u32, chars: &[char]) -> u32 {
|
||||
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
|
||||
// Math.ceil(Math.pow(10, decimalLength * length))
|
||||
|
||||
@@ -32,14 +32,14 @@ fn testMask0() {
|
||||
|
||||
#[test]
|
||||
fn testMask1() {
|
||||
testMaskAcrossDimensions(DataMask::DATA_MASK_001, |i, j| i % 2 == 0);
|
||||
testMaskAcrossDimensionsU8(1, |i, j| i % 2 == 0);
|
||||
testMaskAcrossDimensions(DataMask::DATA_MASK_001, |i, _j| i % 2 == 0);
|
||||
testMaskAcrossDimensionsU8(1, |i, _j| i % 2 == 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn testMask2() {
|
||||
testMaskAcrossDimensions(DataMask::DATA_MASK_010, |i, j| j % 3 == 0);
|
||||
testMaskAcrossDimensionsU8(2, |i, j| j % 3 == 0);
|
||||
testMaskAcrossDimensions(DataMask::DATA_MASK_010, |_i, j| j % 3 == 0);
|
||||
testMaskAcrossDimensionsU8(2, |_i, j| j % 3 == 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -10,7 +10,7 @@ mod qr_code_decoder_meta_data;
|
||||
mod version;
|
||||
|
||||
#[cfg(test)]
|
||||
mod DataMaskTestCase;
|
||||
mod data_mask_testcase;
|
||||
#[cfg(test)]
|
||||
mod DecodedBitStreamParserTestCase;
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -40,6 +40,7 @@ fn test_encode_decode(value: &str) {
|
||||
}
|
||||
|
||||
// Zooms a bit matrix so that each bit is factor x factor
|
||||
#[allow(dead_code)]
|
||||
fn make_larger(input: &BitMatrix, factor: u32) -> BitMatrix {
|
||||
let width = input.getWidth();
|
||||
let mut output = BitMatrix::with_single_dimension(width * factor);
|
||||
@@ -15,4 +15,4 @@ pub use finder_pattern_info::*;
|
||||
pub use qrcode_detector_result::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod DetectorTest;
|
||||
mod cetector_test;
|
||||
|
||||
@@ -128,7 +128,7 @@ fn testXOR() {
|
||||
v1.appendBits(0x5555aaaa, 32).expect("append");
|
||||
let mut v2 = BitArray::new();
|
||||
v2.appendBits(0xaaaa5555, 32).expect("append");
|
||||
v1.xor(&v2);
|
||||
v1.xor(&v2).expect("xor");
|
||||
assert_eq!(0xffffffff, getUnsignedInt(&v1));
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ fn testXOR2() {
|
||||
let mut v1 = BitArray::new();
|
||||
v1.appendBits(0x2a, 7).expect("append"); // 010 1010
|
||||
let mut v2 = BitArray::new();
|
||||
v2.appendBits(0x55, 7); // 101 0101
|
||||
v1.xor(&v2);
|
||||
v2.appendBits(0x55, 7).expect("append"); // 101 0101
|
||||
v1.xor(&v2).expect("xor");
|
||||
assert_eq!(0xfe000000, getUnsignedInt(&v1)); // 1111 1110
|
||||
}
|
||||
|
||||
@@ -13,25 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// package com.google.zxing.qrcode.encoder;
|
||||
|
||||
// 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;
|
||||
/**
|
||||
* @author satorux@google.com (Satoru Takabayashi) - creator
|
||||
* @author dswitkin@google.com (Daniel Switkin) - ported from C++
|
||||
*/
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -51,11 +36,6 @@ use crate::{
|
||||
|
||||
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! {
|
||||
static ref SHIFT_JIS_CHARSET: EncodingRef =
|
||||
encoding::label::encoding_from_whatwg_label("SJIS").unwrap();
|
||||
|
||||
@@ -245,7 +245,7 @@ fn testBuildMatrix() {
|
||||
let mut bits = BitArray::new();
|
||||
for c in bytes {
|
||||
// for (char c: bytes) {
|
||||
bits.appendBits(c, 8);
|
||||
bits.appendBits(c, 8).expect("append");
|
||||
}
|
||||
let mut matrix = ByteMatrix::new(21, 21);
|
||||
matrix_util::buildMatrix(
|
||||
@@ -616,8 +616,8 @@ pub struct Edge {
|
||||
characterLength: u32,
|
||||
previous: Option<Rc<Edge>>,
|
||||
cachedTotalSize: u32,
|
||||
encoders: ECIEncoderSet,
|
||||
stringToEncode: Vec<String>,
|
||||
_encoders: ECIEncoderSet,
|
||||
_stringToEncode: Vec<String>,
|
||||
}
|
||||
impl Edge {
|
||||
pub fn new(
|
||||
@@ -641,7 +641,7 @@ impl Edge {
|
||||
charsetEncoderIndex: nci,
|
||||
characterLength,
|
||||
previous: previous.clone(),
|
||||
stringToEncode: stringToEncode.clone(),
|
||||
_stringToEncode: stringToEncode.clone(),
|
||||
cachedTotalSize: {
|
||||
let mut size = if previous.is_some() {
|
||||
previous.as_ref().unwrap().cachedTotalSize
|
||||
@@ -713,7 +713,7 @@ impl Edge {
|
||||
// }
|
||||
size
|
||||
},
|
||||
encoders,
|
||||
_encoders : encoders,
|
||||
}
|
||||
// this.mode = mode;
|
||||
// this.fromPosition = fromPosition;
|
||||
|
||||
@@ -12,12 +12,12 @@ pub use minimal_encoder::*;
|
||||
pub use qr_code::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod BitVectorTestCase;
|
||||
mod bit_vector_testcase;
|
||||
#[cfg(test)]
|
||||
mod EncoderTestCase;
|
||||
#[cfg(test)]
|
||||
mod MaskUtilTestCase;
|
||||
#[cfg(test)]
|
||||
mod MatrixUtilTestCase;
|
||||
mod matrix_util_testcase;
|
||||
#[cfg(test)]
|
||||
mod QRCodeTestCase;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//package com.google.zxing;
|
||||
|
||||
use std::{any::Any, rc::Rc};
|
||||
use std::{ rc::Rc};
|
||||
|
||||
use crate::pdf417::PDF417RXingResultMetadata;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rxing::{qrcode::QRCodeReader, BarcodeFormat, MultiFormatReader};
|
||||
use rxing::{MultiFormatReader};
|
||||
|
||||
mod common;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user