mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-28 05:12:34 +00:00
rename multi barcode methods to snake case
This commit is contained in:
@@ -40,14 +40,14 @@ use super::MultipleBarcodeReader;
|
|||||||
pub struct GenericMultipleBarcodeReader<T: Reader>(T);
|
pub struct GenericMultipleBarcodeReader<T: Reader>(T);
|
||||||
|
|
||||||
impl<T: Reader> MultipleBarcodeReader for GenericMultipleBarcodeReader<T> {
|
impl<T: Reader> MultipleBarcodeReader for GenericMultipleBarcodeReader<T> {
|
||||||
fn decodeMultiple(
|
fn decode_multiple(
|
||||||
&mut self,
|
&mut self,
|
||||||
image: &crate::BinaryBitmap,
|
image: &crate::BinaryBitmap,
|
||||||
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
|
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
|
||||||
self.decodeMultipleWithHints(image, &HashMap::new())
|
self.decode_multiple_with_hints(image, &HashMap::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decodeMultipleWithHints(
|
fn decode_multiple_with_hints(
|
||||||
&mut self,
|
&mut self,
|
||||||
image: &crate::BinaryBitmap,
|
image: &crate::BinaryBitmap,
|
||||||
hints: &crate::DecodingHintDictionary,
|
hints: &crate::DecodingHintDictionary,
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ fn testMulti() {
|
|||||||
let bitmap = BinaryBitmap::new(Rc::new(HybridBinarizer::new(Box::new(source))));
|
let bitmap = BinaryBitmap::new(Rc::new(HybridBinarizer::new(Box::new(source))));
|
||||||
|
|
||||||
let mut reader = GenericMultipleBarcodeReader::new(MultiFormatReader::default());
|
let mut reader = GenericMultipleBarcodeReader::new(MultiFormatReader::default());
|
||||||
let results = reader.decodeMultiple(&bitmap).expect("must decode multi");
|
let results = reader.decode_multiple(&bitmap).expect("must decode multi");
|
||||||
// assertNotNull(results);
|
// assertNotNull(results);
|
||||||
assert_eq!(2, results.len());
|
assert_eq!(2, results.len());
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ fn testMultiQR() {
|
|||||||
let bitmap = BinaryBitmap::new(Rc::new(HybridBinarizer::new(Box::new(source))));
|
let bitmap = BinaryBitmap::new(Rc::new(HybridBinarizer::new(Box::new(source))));
|
||||||
|
|
||||||
let mut reader = GenericMultipleBarcodeReader::new(MultiFormatReader::default());
|
let mut reader = GenericMultipleBarcodeReader::new(MultiFormatReader::default());
|
||||||
let results = reader.decodeMultiple(&bitmap).expect("must decode multi");
|
let results = reader.decode_multiple(&bitmap).expect("must decode multi");
|
||||||
assert_eq!(4, results.len());
|
assert_eq!(4, results.len());
|
||||||
|
|
||||||
let mut barcodeContents = HashSet::new();
|
let mut barcodeContents = HashSet::new();
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ use crate::{BinaryBitmap, DecodingHintDictionary, Exceptions, RXingResult};
|
|||||||
* @author Sean Owen
|
* @author Sean Owen
|
||||||
*/
|
*/
|
||||||
pub trait MultipleBarcodeReader {
|
pub trait MultipleBarcodeReader {
|
||||||
fn decodeMultiple(&mut self, image: &BinaryBitmap) -> Result<Vec<RXingResult>, Exceptions>;
|
fn decode_multiple(&mut self, image: &BinaryBitmap) -> Result<Vec<RXingResult>, Exceptions>;
|
||||||
|
|
||||||
fn decodeMultipleWithHints(
|
fn decode_multiple_with_hints(
|
||||||
&mut self,
|
&mut self,
|
||||||
image: &BinaryBitmap,
|
image: &BinaryBitmap,
|
||||||
hints: &DecodingHintDictionary,
|
hints: &DecodingHintDictionary,
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ use super::detector::MultiDetector;
|
|||||||
*/
|
*/
|
||||||
pub struct QRCodeMultiReader(QRCodeReader);
|
pub struct QRCodeMultiReader(QRCodeReader);
|
||||||
impl MultipleBarcodeReader for QRCodeMultiReader {
|
impl MultipleBarcodeReader for QRCodeMultiReader {
|
||||||
fn decodeMultiple(
|
fn decode_multiple(
|
||||||
&mut self,
|
&mut self,
|
||||||
image: &crate::BinaryBitmap,
|
image: &crate::BinaryBitmap,
|
||||||
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
|
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
|
||||||
self.decodeMultipleWithHints(image, &HashMap::new())
|
self.decode_multiple_with_hints(image, &HashMap::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decodeMultipleWithHints(
|
fn decode_multiple_with_hints(
|
||||||
&mut self,
|
&mut self,
|
||||||
image: &crate::BinaryBitmap,
|
image: &crate::BinaryBitmap,
|
||||||
hints: &crate::DecodingHintDictionary,
|
hints: &crate::DecodingHintDictionary,
|
||||||
@@ -253,7 +253,7 @@ mod multi_qr_code_test_case {
|
|||||||
let bitmap = BinaryBitmap::new(Rc::new(HybridBinarizer::new(Box::new(source))));
|
let bitmap = BinaryBitmap::new(Rc::new(HybridBinarizer::new(Box::new(source))));
|
||||||
|
|
||||||
let mut reader = QRCodeMultiReader::new();
|
let mut reader = QRCodeMultiReader::new();
|
||||||
let results = reader.decodeMultiple(&bitmap).expect("must decode");
|
let results = reader.decode_multiple(&bitmap).expect("must decode");
|
||||||
// assertNotNull(results);
|
// assertNotNull(results);
|
||||||
assert_eq!(4, results.len());
|
assert_eq!(4, results.len());
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ impl Reader for MultiFormatReader {
|
|||||||
&mut self,
|
&mut self,
|
||||||
image: &crate::BinaryBitmap,
|
image: &crate::BinaryBitmap,
|
||||||
) -> Result<crate::RXingResult, crate::Exceptions> {
|
) -> Result<crate::RXingResult, crate::Exceptions> {
|
||||||
self.setHints(&HashMap::new());
|
self.set_ints(&HashMap::new());
|
||||||
self.decodeInternal(image)
|
self.decode_internal(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,8 +67,8 @@ impl Reader for MultiFormatReader {
|
|||||||
image: &crate::BinaryBitmap,
|
image: &crate::BinaryBitmap,
|
||||||
hints: &crate::DecodingHintDictionary,
|
hints: &crate::DecodingHintDictionary,
|
||||||
) -> Result<crate::RXingResult, crate::Exceptions> {
|
) -> Result<crate::RXingResult, crate::Exceptions> {
|
||||||
self.setHints(hints);
|
self.set_ints(hints);
|
||||||
self.decodeInternal(image)
|
self.decode_internal(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reset(&mut self) {
|
fn reset(&mut self) {
|
||||||
@@ -89,12 +89,12 @@ impl MultiFormatReader {
|
|||||||
* @return The contents of the image
|
* @return The contents of the image
|
||||||
* @throws NotFoundException Any errors which occurred
|
* @throws NotFoundException Any errors which occurred
|
||||||
*/
|
*/
|
||||||
pub fn decodeWithState(&mut self, image: &BinaryBitmap) -> Result<RXingResult, Exceptions> {
|
pub fn decode_with_state(&mut self, image: &BinaryBitmap) -> Result<RXingResult, Exceptions> {
|
||||||
// Make sure to set up the default state so we don't crash
|
// Make sure to set up the default state so we don't crash
|
||||||
if self.readers.is_empty() {
|
if self.readers.is_empty() {
|
||||||
self.setHints(&HashMap::new());
|
self.set_ints(&HashMap::new());
|
||||||
}
|
}
|
||||||
self.decodeInternal(image)
|
self.decode_internal(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +104,7 @@ impl MultiFormatReader {
|
|||||||
*
|
*
|
||||||
* @param hints The set of hints to use for subsequent calls to decode(image)
|
* @param hints The set of hints to use for subsequent calls to decode(image)
|
||||||
*/
|
*/
|
||||||
pub fn setHints(&mut self, hints: &DecodingHintDictionary) {
|
pub fn set_ints(&mut self, hints: &DecodingHintDictionary) {
|
||||||
self.hints = hints.clone(); // {hint} else {HashMap::new()};
|
self.hints = hints.clone(); // {hint} else {HashMap::new()};
|
||||||
|
|
||||||
let tryHarder = self.hints.contains_key(&DecodeHintType::TRY_HARDER);
|
let tryHarder = self.hints.contains_key(&DecodeHintType::TRY_HARDER);
|
||||||
@@ -166,7 +166,7 @@ impl MultiFormatReader {
|
|||||||
self.readers = readers; //Vec::new(); //readers.toArray(EMPTY_READER_ARRAY);
|
self.readers = readers; //Vec::new(); //readers.toArray(EMPTY_READER_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decodeInternal(&mut self, image: &BinaryBitmap) -> Result<RXingResult, Exceptions> {
|
pub fn decode_internal(&mut self, image: &BinaryBitmap) -> Result<RXingResult, Exceptions> {
|
||||||
if !self.readers.is_empty() {
|
if !self.readers.is_empty() {
|
||||||
for reader in self.readers.iter_mut() {
|
for reader in self.readers.iter_mut() {
|
||||||
// I'm not sure how to model this in rust
|
// I'm not sure how to model this in rust
|
||||||
|
|||||||
@@ -63,14 +63,14 @@ impl Reader for PDF417Reader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl MultipleBarcodeReader for PDF417Reader {
|
impl MultipleBarcodeReader for PDF417Reader {
|
||||||
fn decodeMultiple(
|
fn decode_multiple(
|
||||||
&mut self,
|
&mut self,
|
||||||
image: &crate::BinaryBitmap,
|
image: &crate::BinaryBitmap,
|
||||||
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
|
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
|
||||||
self.decodeMultipleWithHints(image, &HashMap::new())
|
self.decode_multiple_with_hints(image, &HashMap::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decodeMultipleWithHints(
|
fn decode_multiple_with_hints(
|
||||||
&mut self,
|
&mut self,
|
||||||
image: &crate::BinaryBitmap,
|
image: &crate::BinaryBitmap,
|
||||||
hints: &crate::DecodingHintDictionary,
|
hints: &crate::DecodingHintDictionary,
|
||||||
|
|||||||
@@ -748,7 +748,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
|
|||||||
hints.insert(DecodeHintType::TRY_HARDER, DecodeHintValue::TryHarder(true));
|
hints.insert(DecodeHintType::TRY_HARDER, DecodeHintValue::TryHarder(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
barcode_reader.decodeMultipleWithHints(source, &hints)
|
barcode_reader.decode_multiple_with_hints(source, &hints)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_image_file_lists(&self) -> Result<HashMap<String, Vec<PathBuf>>, std::io::Error> {
|
fn get_image_file_lists(&self) -> Result<HashMap<String, Vec<PathBuf>>, std::io::Error> {
|
||||||
|
|||||||
Reference in New Issue
Block a user