cargo fmt

This commit is contained in:
Henry Schimke
2023-01-28 18:34:38 -06:00
parent e024573905
commit 9ffc5769ba
4 changed files with 29 additions and 19 deletions

View File

@@ -52,18 +52,25 @@ impl Decoder {
pub fn decode(&self, bits: &BitMatrix) -> Result<DecoderRXingResult, Exceptions> { pub fn decode(&self, bits: &BitMatrix) -> Result<DecoderRXingResult, Exceptions> {
let decoded = self.perform_decode(bits, false); let decoded = self.perform_decode(bits, false);
if decoded.is_ok() { if decoded.is_ok() {
return decoded return decoded;
} }
self.perform_decode(&Self::flip_bitmatrix(bits)?, false) self.perform_decode(&Self::flip_bitmatrix(bits)?, false)
} }
fn flip_bitmatrix( bits:&BitMatrix) -> Result<BitMatrix,Exceptions> fn flip_bitmatrix(bits: &BitMatrix) -> Result<BitMatrix, Exceptions> {
{
let mut res = BitMatrix::new(bits.getHeight(), bits.getWidth())?; let mut res = BitMatrix::new(bits.getHeight(), bits.getWidth())?;
for y in 0..res.getHeight() { for y in 0..res.getHeight() {
for x in 0..res.getWidth() { for x in 0..res.getWidth() {
{res.set_bool(x, y, bits.get(bits.getWidth() - 1 - y, bits.getHeight() - 1 - x));}}} {
res.set_bool(
x,
y,
bits.get(bits.getWidth() - 1 - y, bits.getHeight() - 1 - x),
);
}
}
}
Ok(res) Ok(res)
} }
@@ -90,7 +97,11 @@ impl Decoder {
* @throws FormatException if the Data Matrix Code cannot be decoded * @throws FormatException if the Data Matrix Code cannot be decoded
* @throws ChecksumException if error correction fails * @throws ChecksumException if error correction fails
*/ */
fn perform_decode(&self, bits: &BitMatrix, fix259: bool) -> Result<DecoderRXingResult, Exceptions> { fn perform_decode(
&self,
bits: &BitMatrix,
fix259: bool,
) -> Result<DecoderRXingResult, Exceptions> {
// Construct a parser and read version, error-correction level // Construct a parser and read version, error-correction level
let mut parser = BitMatrixParser::new(bits)?; let mut parser = BitMatrixParser::new(bits)?;
@@ -120,7 +131,7 @@ impl Decoder {
if errors_corrected.is_err() && !fix259 { if errors_corrected.is_err() && !fix259 {
return self.perform_decode(bits, true); return self.perform_decode(bits, true);
} else if errors_corrected.is_err() { } else if errors_corrected.is_err() {
return Err(errors_corrected.err().unwrap()) return Err(errors_corrected.err().unwrap());
} }
for i in 0..numDataCodewords { for i in 0..numDataCodewords {
// for (int i = 0; i < numDataCodewords; i++) { // for (int i = 0; i < numDataCodewords; i++) {

View File

@@ -693,8 +693,7 @@ fn decodeECISegment(bits: &mut BitSource, result: &mut ECIStringBuilder) -> Resu
let thirdByte = bits.readBits(8)?; let thirdByte = bits.readBits(8)?;
result result.appendECI((firstByte - 192) * 64516 + 16383 + (secondByte - 1) * 254 + thirdByte - 1)
.appendECI((firstByte - 192) * 64516 + 16383 + (secondByte - 1) * 254 + thirdByte - 1)
// if bits.available() < 8 { // if bits.available() < 8 {
// return Err(Exceptions::FormatException(None)); // return Err(Exceptions::FormatException(None));