Merge branch 'main' into pr/exception_helpers

This commit is contained in:
Vukašin Stepanović
2023-02-16 07:15:51 +00:00
161 changed files with 900 additions and 933 deletions

View File

@@ -16,6 +16,7 @@
use std::collections::HashMap;
use crate::common::Result;
use crate::{Exceptions, RXingResult, RXingResultPoint, Reader, ResultPoint};
/**
@@ -29,10 +30,7 @@ use crate::{Exceptions, RXingResult, RXingResultPoint, Reader, ResultPoint};
*/
pub struct ByQuadrantReader<T: Reader>(T);
impl<T: Reader> Reader for ByQuadrantReader<T> {
fn decode(
&mut self,
image: &mut crate::BinaryBitmap,
) -> Result<crate::RXingResult, crate::Exceptions> {
fn decode(&mut self, image: &mut crate::BinaryBitmap) -> Result<crate::RXingResult> {
self.decode_with_hints(image, &HashMap::new())
}
@@ -40,7 +38,7 @@ impl<T: Reader> Reader for ByQuadrantReader<T> {
&mut self,
image: &mut crate::BinaryBitmap,
hints: &crate::DecodingHintDictionary,
) -> Result<crate::RXingResult, crate::Exceptions> {
) -> Result<crate::RXingResult> {
let width = image.getWidth();
let height = image.getHeight();
let halfWidth = width / 2;

View File

@@ -17,8 +17,8 @@
use std::collections::HashMap;
use crate::{
BinaryBitmap, DecodingHintDictionary, Exceptions, RXingResult, RXingResultPoint, Reader,
ResultPoint,
common::Result, BinaryBitmap, DecodingHintDictionary, Exceptions, RXingResult,
RXingResultPoint, Reader, ResultPoint,
};
use super::MultipleBarcodeReader;
@@ -44,7 +44,7 @@ impl<T: Reader> MultipleBarcodeReader for GenericMultipleBarcodeReader<T> {
fn decode_multiple(
&mut self,
image: &mut crate::BinaryBitmap,
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
) -> Result<Vec<crate::RXingResult>> {
self.decode_multiple_with_hints(image, &HashMap::new())
}
@@ -52,7 +52,7 @@ impl<T: Reader> MultipleBarcodeReader for GenericMultipleBarcodeReader<T> {
&mut self,
image: &mut crate::BinaryBitmap,
hints: &crate::DecodingHintDictionary,
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
) -> Result<Vec<crate::RXingResult>> {
let mut results = Vec::new();
self.doDecodeMultiple(image, hints, &mut results, 0, 0, 0);
if results.is_empty() {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
use crate::{BinaryBitmap, DecodingHintDictionary, Exceptions, RXingResult};
use crate::{common::Result, BinaryBitmap, DecodingHintDictionary, RXingResult};
/**
* Implementation of this interface attempt to read several barcodes from one image.
@@ -23,12 +23,11 @@ use crate::{BinaryBitmap, DecodingHintDictionary, Exceptions, RXingResult};
* @author Sean Owen
*/
pub trait MultipleBarcodeReader {
fn decode_multiple(&mut self, image: &mut BinaryBitmap)
-> Result<Vec<RXingResult>, Exceptions>;
fn decode_multiple(&mut self, image: &mut BinaryBitmap) -> Result<Vec<RXingResult>>;
fn decode_multiple_with_hints(
&mut self,
image: &mut BinaryBitmap,
hints: &DecodingHintDictionary,
) -> Result<Vec<RXingResult>, Exceptions>;
) -> Result<Vec<RXingResult>>;
}

View File

@@ -15,7 +15,7 @@
*/
use crate::{
common::BitMatrix,
common::{BitMatrix, Result},
qrcode::detector::{Detector, QRCodeDetectorResult},
DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
};
@@ -37,10 +37,7 @@ impl<'a> MultiDetector<'_> {
// private static final DetectorRXingResult[] EMPTY_DETECTOR_RESULTS = new DetectorRXingResult[0];
pub fn detectMulti(
&self,
hints: &DecodingHintDictionary,
) -> Result<Vec<QRCodeDetectorResult>, Exceptions> {
pub fn detectMulti(&self, hints: &DecodingHintDictionary) -> Result<Vec<QRCodeDetectorResult>> {
let image = self.0.getImage();
let resultPointCallback = if let Some(DecodeHintValue::NeedResultPointCallback(cb)) =
hints.get(&DecodeHintType::NEED_RESULT_POINT_CALLBACK)

View File

@@ -17,7 +17,7 @@
use std::cmp::Ordering;
use crate::{
common::BitMatrix,
common::{BitMatrix, Result},
qrcode::detector::{FinderPattern, FinderPatternFinder, FinderPatternInfo},
result_point_utils, DecodeHintType, DecodingHintDictionary, Exceptions,
RXingResultPointCallback,
@@ -82,7 +82,7 @@ impl<'a> MultiFinderPatternFinder<'_> {
* size differs from the average among those patterns the least
* @throws NotFoundException if 3 such finder patterns do not exist
*/
fn selectMultipleBestPatterns(&self) -> Result<Vec<[FinderPattern; 3]>, Exceptions> {
fn selectMultipleBestPatterns(&self) -> Result<Vec<[FinderPattern; 3]>> {
let mut possibleCenters = Vec::new();
for fp in self.0.getPossibleCenters() {
if fp.getCount() >= 2 {
@@ -216,10 +216,7 @@ impl<'a> MultiFinderPatternFinder<'_> {
}
}
pub fn findMulti(
&mut self,
hints: &DecodingHintDictionary,
) -> Result<Vec<FinderPatternInfo>, Exceptions> {
pub fn findMulti(&mut self, hints: &DecodingHintDictionary) -> Result<Vec<FinderPatternInfo>> {
let tryHarder = hints.contains_key(&DecodeHintType::TRY_HARDER);
let image = self.0.getImage().clone();
let maxI = image.getHeight();

View File

@@ -17,7 +17,7 @@
use std::{cmp::Ordering, collections::HashMap};
use crate::{
common::DetectorRXingResult,
common::{DetectorRXingResult, Result},
multi::MultipleBarcodeReader,
qrcode::{
decoder::{self, QRCodeDecoderMetaData},
@@ -40,7 +40,7 @@ impl MultipleBarcodeReader for QRCodeMultiReader {
fn decode_multiple(
&mut self,
image: &mut crate::BinaryBitmap,
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
) -> Result<Vec<crate::RXingResult>> {
self.decode_multiple_with_hints(image, &HashMap::new())
}
@@ -48,11 +48,11 @@ impl MultipleBarcodeReader for QRCodeMultiReader {
&mut self,
image: &mut crate::BinaryBitmap,
hints: &crate::DecodingHintDictionary,
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
) -> Result<Vec<crate::RXingResult>> {
let mut results = Vec::new();
let detectorRXingResults = MultiDetector::new(image.getBlackMatrix()).detectMulti(hints)?;
for detectorRXingResult in detectorRXingResults {
let mut proc = || -> Result<(), Exceptions> {
let mut proc = || -> Result<()> {
let decoderRXingResult = decoder::qrcode_decoder::decode_bitmatrix_with_hints(
detectorRXingResult.getBits(),
hints,
@@ -126,7 +126,7 @@ impl QRCodeMultiReader {
Self(QRCodeReader::new())
}
fn processStructuredAppend(results: Vec<RXingResult>) -> Result<Vec<RXingResult>, Exceptions> {
fn processStructuredAppend(results: Vec<RXingResult>) -> Result<Vec<RXingResult>> {
let mut newRXingResults = Vec::new();
let mut saRXingResults = Vec::new();
for result in &results {