From e095de835d98836578f6fc295309e69af7537cd4 Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Tue, 3 Jan 2023 06:39:00 -0600 Subject: [PATCH] Add default for most readers --- src/aztec/aztec_reader.rs | 1 + src/datamatrix/data_matrix_reader.rs | 1 + src/maxicode/maxi_code_reader.rs | 1 + src/multi/generic_multiple_barcode_reader.rs | 1 + src/multi/qrcode/qr_code_multi_reader.rs | 1 + src/multi_format_reader.rs | 20 +++++++-------- src/oned/code_39_reader.rs | 2 +- src/oned/code_93_reader.rs | 2 +- src/oned/multi_format_one_d_reader.rs | 27 ++++++++++---------- src/oned/rss/rss_14_reader.rs | 1 + src/qrcode/qr_code_reader.rs | 1 + 11 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/aztec/aztec_reader.rs b/src/aztec/aztec_reader.rs index 8790b8e..b04dc85 100644 --- a/src/aztec/aztec_reader.rs +++ b/src/aztec/aztec_reader.rs @@ -30,6 +30,7 @@ use super::{decoder, detector::Detector}; * * @author David Olivier */ +#[derive(Default)] pub struct AztecReader; impl Reader for AztecReader { diff --git a/src/datamatrix/data_matrix_reader.rs b/src/datamatrix/data_matrix_reader.rs index 10028eb..5d5f057 100644 --- a/src/datamatrix/data_matrix_reader.rs +++ b/src/datamatrix/data_matrix_reader.rs @@ -35,6 +35,7 @@ lazy_static! { * * @author bbrown@google.com (Brian Brown) */ +#[derive(Default)] pub struct DataMatrixReader; // private static final RXingResultPoint[] NO_POINTS = new RXingResultPoint[0]; diff --git a/src/maxicode/maxi_code_reader.rs b/src/maxicode/maxi_code_reader.rs index 43022dc..5b27afc 100644 --- a/src/maxicode/maxi_code_reader.rs +++ b/src/maxicode/maxi_code_reader.rs @@ -25,6 +25,7 @@ use super::decoder::decoder; /** * This implementation can detect and decode a MaxiCode in an image. */ +#[derive(Default)] pub struct MaxiCodeReader { // private final Decoder decoder = new Decoder(); } diff --git a/src/multi/generic_multiple_barcode_reader.rs b/src/multi/generic_multiple_barcode_reader.rs index 405c38f..080ca22 100644 --- a/src/multi/generic_multiple_barcode_reader.rs +++ b/src/multi/generic_multiple_barcode_reader.rs @@ -37,6 +37,7 @@ use super::MultipleBarcodeReader; * * @author Sean Owen */ +#[derive(Default)] pub struct GenericMultipleBarcodeReader(T); impl MultipleBarcodeReader for GenericMultipleBarcodeReader { diff --git a/src/multi/qrcode/qr_code_multi_reader.rs b/src/multi/qrcode/qr_code_multi_reader.rs index 3c97054..cb900e3 100644 --- a/src/multi/qrcode/qr_code_multi_reader.rs +++ b/src/multi/qrcode/qr_code_multi_reader.rs @@ -34,6 +34,7 @@ use super::detector::MultiDetector; * @author Sean Owen * @author Hannes Erven */ +#[derive(Default)] pub struct QRCodeMultiReader(QRCodeReader); impl MultipleBarcodeReader for QRCodeMultiReader { fn decode_multiple( diff --git a/src/multi_format_reader.rs b/src/multi_format_reader.rs index f8c2cfb..6922bc3 100644 --- a/src/multi_format_reader.rs +++ b/src/multi_format_reader.rs @@ -131,19 +131,19 @@ impl MultiFormatReader { readers.push(Box::new(MultiFormatOneDReader::new(hints))); } if formats.contains(&BarcodeFormat::QR_CODE) { - readers.push(Box::new(QRCodeReader {})); + readers.push(Box::::default()); } if formats.contains(&BarcodeFormat::DATA_MATRIX) { - readers.push(Box::new(DataMatrixReader {})); + readers.push(Box::::default()); } if formats.contains(&BarcodeFormat::AZTEC) { - readers.push(Box::new(AztecReader {})); + readers.push(Box::::default()); } if formats.contains(&BarcodeFormat::PDF_417) { - readers.push(Box::new(PDF417Reader {})); + readers.push(Box::::default()); } if formats.contains(&BarcodeFormat::MAXICODE) { - readers.push(Box::new(MaxiCodeReader {})); + readers.push(Box::::default()); } // At end in "try harder" mode if addOneDReader && tryHarder { @@ -155,11 +155,11 @@ impl MultiFormatReader { readers.push(Box::new(MultiFormatOneDReader::new(hints))); } - readers.push(Box::new(QRCodeReader {})); - readers.push(Box::new(DataMatrixReader {})); - readers.push(Box::new(AztecReader {})); - readers.push(Box::new(PDF417Reader {})); - readers.push(Box::new(MaxiCodeReader {})); + readers.push(Box::::default()); + readers.push(Box::::default()); + readers.push(Box::::default()); + readers.push(Box::::default()); + readers.push(Box::::default()); // unimplemented!(""); if tryHarder { diff --git a/src/oned/code_39_reader.rs b/src/oned/code_39_reader.rs index e46aefe..0d1d6cc 100644 --- a/src/oned/code_39_reader.rs +++ b/src/oned/code_39_reader.rs @@ -27,7 +27,7 @@ use super::{one_d_reader, OneDReader}; * @author Sean Owen * @see Code93Reader */ -#[derive(OneDReader)] +#[derive(OneDReader,Default)] pub struct Code39Reader { usingCheckDigit: bool, extendedMode: bool, diff --git a/src/oned/code_93_reader.rs b/src/oned/code_93_reader.rs index 7922418..f9b50ff 100644 --- a/src/oned/code_93_reader.rs +++ b/src/oned/code_93_reader.rs @@ -26,7 +26,7 @@ use super::{one_d_reader, OneDReader}; * @author Sean Owen * @see Code39Reader */ -#[derive(OneDReader)] +#[derive(OneDReader,Default)] pub struct Code93Reader { decodeRowRXingResult: String, counters: [u32; 6], diff --git a/src/oned/multi_format_one_d_reader.rs b/src/oned/multi_format_one_d_reader.rs index 3867b8a..1b686d1 100644 --- a/src/oned/multi_format_one_d_reader.rs +++ b/src/oned/multi_format_one_d_reader.rs @@ -31,6 +31,7 @@ use crate::Exceptions; * @author dswitkin@google.com (Daniel Switkin) * @author Sean Owen */ +#[derive(Default)] pub struct MultiFormatOneDReader(Vec>); impl OneDReader for MultiFormatOneDReader { fn decodeRow( @@ -77,33 +78,33 @@ impl MultiFormatOneDReader { ))); } if possibleFormats.contains(&BarcodeFormat::CODE_93) { - readers.push(Box::new(Code93Reader::new())); + readers.push(Box::::default()); } if possibleFormats.contains(&BarcodeFormat::CODE_128) { - readers.push(Box::new(Code128Reader {})); + readers.push(Box::::default()); } if possibleFormats.contains(&BarcodeFormat::ITF) { - readers.push(Box::new(ITFReader::default())); + readers.push(Box::::default()); } if possibleFormats.contains(&BarcodeFormat::CODABAR) { - readers.push(Box::new(CodaBarReader::new())); + readers.push(Box::::default()); } if possibleFormats.contains(&BarcodeFormat::RSS_14) { - readers.push(Box::new(RSS14Reader::new())); + readers.push(Box::::default()); } if possibleFormats.contains(&BarcodeFormat::RSS_EXPANDED) { - readers.push(Box::new(RSSExpandedReader::new())); + readers.push(Box::::default()); } } if readers.is_empty() { readers.push(Box::new(MultiFormatUPCEANReader::new(hints))); - readers.push(Box::new(Code39Reader::new())); - readers.push(Box::new(CodaBarReader::new())); - readers.push(Box::new(Code93Reader::new())); - readers.push(Box::new(Code128Reader {})); - readers.push(Box::new(ITFReader::default())); - readers.push(Box::new(RSS14Reader::new())); - readers.push(Box::new(RSSExpandedReader::new())); + readers.push(Box::::default()); + readers.push(Box::::default()); + readers.push(Box::::default()); + readers.push(Box::::default()); + readers.push(Box::::default()); + readers.push(Box::::default()); + readers.push(Box::::default()); } Self(readers) diff --git a/src/oned/rss/rss_14_reader.rs b/src/oned/rss/rss_14_reader.rs index 27a2186..e179bd1 100644 --- a/src/oned/rss/rss_14_reader.rs +++ b/src/oned/rss/rss_14_reader.rs @@ -30,6 +30,7 @@ use super::{ /** * Decodes RSS-14, including truncated and stacked variants. See ISO/IEC 24724:2006. */ +#[derive(Default)] pub struct RSS14Reader { possibleLeftPairs: Vec, possibleRightPairs: Vec, diff --git a/src/qrcode/qr_code_reader.rs b/src/qrcode/qr_code_reader.rs index f20bf58..225a6f0 100644 --- a/src/qrcode/qr_code_reader.rs +++ b/src/qrcode/qr_code_reader.rs @@ -32,6 +32,7 @@ use super::{ * * @author Sean Owen */ +#[derive(Default)] pub struct QRCodeReader; // pub struct QRCodeReader; {