refactor to use common result type

This commit is contained in:
Vukašin Stepanović
2023-02-14 22:56:03 +00:00
parent 145cf704fe
commit 8ee616d96b
160 changed files with 829 additions and 901 deletions

View File

@@ -16,7 +16,10 @@
use rxing_one_d_proc_derive::OneDReader;
use crate::{common::BitArray, BarcodeFormat, Exceptions, RXingResult};
use crate::{
common::{BitArray, Result},
BarcodeFormat, Exceptions, RXingResult,
};
use super::{one_d_reader, OneDReader};
@@ -34,7 +37,7 @@ impl OneDReader for Code128Reader {
rowNumber: u32,
row: &crate::common::BitArray,
hints: &crate::DecodingHintDictionary,
) -> Result<crate::RXingResult, crate::Exceptions> {
) -> Result<crate::RXingResult> {
let convertFNC1 = hints.contains_key(&DecodeHintType::ASSUME_GS1);
let mut symbologyModifier = 0;
@@ -354,7 +357,7 @@ impl OneDReader for Code128Reader {
}
}
impl Code128Reader {
fn findStartPattern(&self, row: &BitArray) -> Result<[usize; 3], Exceptions> {
fn findStartPattern(&self, row: &BitArray) -> Result<[usize; 3]> {
let width = row.getSize();
let rowOffset = row.getNextSet(0);
@@ -410,12 +413,7 @@ impl Code128Reader {
Err(Exceptions::NotFoundException(None))
}
fn decodeCode(
&self,
row: &BitArray,
counters: &mut [u32; 6],
rowOffset: usize,
) -> Result<u8, Exceptions> {
fn decodeCode(&self, row: &BitArray, counters: &mut [u32; 6], rowOffset: usize) -> Result<u8> {
one_d_reader::recordPattern(row, rowOffset, counters)?;
let mut bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
let mut bestMatch = -1_isize;