many warnings cleaned up

This commit is contained in:
Henry Schimke
2022-12-30 16:19:45 -06:00
parent 6a9ac8fa89
commit b383d7b0d4
48 changed files with 107 additions and 127 deletions

View File

@@ -19,7 +19,7 @@ use std::collections::HashMap;
use crate::{
common::{BitMatrix, DetectorRXingResult},
BarcodeFormat, DecodeHintType, Exceptions, RXingResult, RXingResultMetadataType,
RXingResultMetadataValue, RXingResultPoint, Reader,
RXingResultMetadataValue, Reader,
};
use super::{decoder::Decoder, detector::Detector};
@@ -27,7 +27,7 @@ use super::{decoder::Decoder, detector::Detector};
use lazy_static::lazy_static;
lazy_static! {
static ref decoder: Decoder = Decoder::new();
static ref DECODER: Decoder = Decoder::new();
}
/**
@@ -74,11 +74,11 @@ impl Reader for DataMatrixReader {
let mut points = Vec::new();
if hints.contains_key(&DecodeHintType::PURE_BARCODE) {
let bits = self.extractPureBits(image.getBlackMatrix())?;
decoderRXingResult = decoder.decode(&bits)?;
decoderRXingResult = DECODER.decode(&bits)?;
points.clear();
} else {
let detectorRXingResult = Detector::new(image.getBlackMatrix().clone())?.detect()?;
decoderRXingResult = decoder.decode(detectorRXingResult.getBits())?;
decoderRXingResult = DECODER.decode(detectorRXingResult.getBits())?;
points = detectorRXingResult.getPoints().clone();
}
let mut result = RXingResult::new(

View File

@@ -589,7 +589,7 @@ fn decodeEdifactSegment(
// Read rest of byte, which should be 0, and stop
let bitsLeft = 8 - bits.getBitOffset();
if bitsLeft != 8 {
bits.readBits(bitsLeft);
bits.readBits(bitsLeft)?;
}
return Ok(());
}
@@ -633,9 +633,10 @@ fn decodeBase256Segment(
}
// We're seeing NegativeArraySizeException errors from users.
if count < 0 {
return Err(Exceptions::FormatException("".to_owned()));
}
// but we shouldn't in rust because it's unsigned
// if count < 0 {
// return Err(Exceptions::FormatException("".to_owned()));
// }
let mut bytes = vec![0u8; count as usize];
for i in 0..count as usize {

View File

@@ -49,7 +49,7 @@ impl Encoder for X12Encoder {
}
}
}
Self::handleEOD(context, &mut buffer);
Self::handleEOD(context, &mut buffer)?;
Ok(())
}
}
@@ -70,7 +70,7 @@ impl X12Encoder {
} else if c >= 'A' && c <= 'Z' {
sb.push((c as u8 - 65 + 14) as char);
} else {
high_level_encoder::illegalCharacter(c);
high_level_encoder::illegalCharacter(c).expect("detect_illegal_character");
}
}
}