mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
refactor to use common result type
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
use super::{OneDReader, UPCEANReader, L_AND_G_PATTERNS};
|
||||
use crate::{BarcodeFormat, Exceptions};
|
||||
use crate::{common::Result, BarcodeFormat, Exceptions};
|
||||
use rxing_one_d_proc_derive::{EANReader, OneDReader};
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ impl UPCEANReader for UPCEReader {
|
||||
row: &crate::common::BitArray,
|
||||
startRange: &[usize; 2],
|
||||
resultString: &mut String,
|
||||
) -> Result<usize, Exceptions> {
|
||||
) -> Result<usize> {
|
||||
let mut counters = [0_u32; 4];
|
||||
|
||||
let end = row.getSize();
|
||||
@@ -67,17 +67,13 @@ impl UPCEANReader for UPCEReader {
|
||||
Ok(rowOffset)
|
||||
}
|
||||
|
||||
fn checkChecksum(&self, s: &str) -> Result<bool, Exceptions> {
|
||||
fn checkChecksum(&self, s: &str) -> Result<bool> {
|
||||
self.checkStandardUPCEANChecksum(
|
||||
&convertUPCEtoUPCA(s).ok_or(Exceptions::IllegalArgumentException(None))?,
|
||||
)
|
||||
}
|
||||
|
||||
fn decodeEnd(
|
||||
&self,
|
||||
row: &crate::common::BitArray,
|
||||
endStart: usize,
|
||||
) -> Result<[usize; 2], Exceptions> {
|
||||
fn decodeEnd(&self, row: &crate::common::BitArray, endStart: usize) -> Result<[usize; 2]> {
|
||||
self.findGuardPattern(row, endStart, true, &Self::MIDDLE_END_PATTERN)
|
||||
}
|
||||
}
|
||||
@@ -126,7 +122,7 @@ impl UPCEReader {
|
||||
fn determineNumSysAndCheckDigit(
|
||||
resultString: &mut String,
|
||||
lgPatternFound: usize,
|
||||
) -> Result<(), Exceptions> {
|
||||
) -> Result<()> {
|
||||
for numSys in 0..=1 {
|
||||
for d in 0..10 {
|
||||
if lgPatternFound == Self::NUMSYS_AND_CHECK_DIGIT_PATTERNS[numSys][d] {
|
||||
|
||||
Reference in New Issue
Block a user