Initial generics

This commit is contained in:
Steve Cook
2023-03-01 22:08:12 -05:00
parent 26325928e7
commit a9bc58108c
65 changed files with 1013 additions and 883 deletions

View File

@@ -16,7 +16,7 @@
use crate::{
common::{BitMatrix, Result},
point, BinaryBitmap, DecodingHintDictionary, Exceptions, Point,
point, Binarizer, BinaryBitmap, DecodingHintDictionary, Exceptions, Point,
};
use std::borrow::Cow;
@@ -64,8 +64,8 @@ const ROTATIONS: [u32; 4] = [0, 180, 270, 90];
* @return {@link PDF417DetectorRXingResult} encapsulating results of detecting a PDF417 code
* @throws NotFoundException if no PDF417 Code can be found
*/
pub fn detect_with_hints(
image: &mut BinaryBitmap,
pub fn detect_with_hints<B: Binarizer>(
image: &mut BinaryBitmap<B>,
_hints: &DecodingHintDictionary,
multiple: bool,
) -> Result<PDF417DetectorRXingResult> {
@@ -74,7 +74,7 @@ pub fn detect_with_hints(
//boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
//let try_harder = matches!(hints.get(&DecodeHintType::TRY_HARDER), Some(DecodeHintValue::TryHarder(true)));
let originalMatrix = image.getBlackMatrix();
let originalMatrix = image.get_black_matrix();
for rotation in ROTATIONS {
// for (int rotation : ROTATIONS) {
let bitMatrix = applyRotation(originalMatrix, rotation)?;

View File

@@ -17,7 +17,7 @@
use std::collections::HashMap;
use crate::{
common::Result, multi::MultipleBarcodeReader, BarcodeFormat, BinaryBitmap,
common::Result, multi::MultipleBarcodeReader, BarcodeFormat, Binarizer, BinaryBitmap,
DecodingHintDictionary, Exceptions, Point, RXingResult, RXingResultMetadataType,
RXingResultMetadataValue, Reader,
};
@@ -43,13 +43,13 @@ impl Reader for PDF417Reader {
* @throws NotFoundException if a PDF417 code cannot be found,
* @throws FormatException if a PDF417 cannot be decoded
*/
fn decode(&mut self, image: &mut crate::BinaryBitmap) -> Result<crate::RXingResult> {
fn decode<B: Binarizer>(&mut self, image: &mut BinaryBitmap<B>) -> Result<RXingResult> {
self.decode_with_hints(image, &HashMap::new())
}
fn decode_with_hints(
fn decode_with_hints<B: Binarizer>(
&mut self,
image: &mut crate::BinaryBitmap,
image: &mut BinaryBitmap<B>,
hints: &crate::DecodingHintDictionary,
) -> Result<crate::RXingResult> {
let result = Self::decode(image, hints, false)?;
@@ -61,18 +61,18 @@ impl Reader for PDF417Reader {
}
impl MultipleBarcodeReader for PDF417Reader {
fn decode_multiple(
fn decode_multiple<B: Binarizer>(
&mut self,
image: &mut crate::BinaryBitmap,
) -> Result<Vec<crate::RXingResult>> {
image: &mut BinaryBitmap<B>,
) -> Result<Vec<RXingResult>> {
self.decode_multiple_with_hints(image, &HashMap::new())
}
fn decode_multiple_with_hints(
fn decode_multiple_with_hints<B: Binarizer>(
&mut self,
image: &mut crate::BinaryBitmap,
hints: &crate::DecodingHintDictionary,
) -> Result<Vec<crate::RXingResult>> {
image: &mut BinaryBitmap<B>,
hints: &DecodingHintDictionary,
) -> Result<Vec<RXingResult>> {
Self::decode(image, hints, true)
}
}
@@ -82,8 +82,8 @@ impl PDF417Reader {
Self::default()
}
fn decode(
image: &mut BinaryBitmap,
fn decode<B: Binarizer>(
image: &mut BinaryBitmap<B>,
hints: &DecodingHintDictionary,
multiple: bool,
) -> Result<Vec<RXingResult>> {