cargo clippy && fmt

This commit is contained in:
Henry Schimke
2023-03-02 15:54:40 -06:00
parent a0b8b68869
commit 9431031147
28 changed files with 111 additions and 135 deletions

View File

@@ -18,7 +18,7 @@
use std::collections::HashMap;
use crate::{
common::{BitMatrix, Result, CharacterSetECI},
common::{BitMatrix, CharacterSetECI, Result},
qrcode::encoder::ByteMatrix,
BarcodeFormat, EncodeHintType, EncodeHintValue, Exceptions, Writer,
};
@@ -122,7 +122,8 @@ impl Writer for DataMatrixWriter {
hints.get(&EncodeHintType::CHARACTER_SET) else {
return Err(Exceptions::illegal_argument_with("charset does not exist"))
};
charset = CharacterSetECI::getCharacterSetECIByName(char_set_name);//encoding::label::encoding_from_whatwg_label(char_set_name);
charset = CharacterSetECI::getCharacterSetECIByName(char_set_name);
//encoding::label::encoding_from_whatwg_label(char_set_name);
// charset = Charset.forName(hints.get(EncodeHintType.CHARACTER_SET).toString());
}
encoded = minimal_encoder::encodeHighLevelWithDetails(

View File

@@ -15,7 +15,7 @@
*/
use crate::{
common::{BitSource, DecoderRXingResult, ECIStringBuilder, Result, CharacterSetECI},
common::{BitSource, CharacterSetECI, DecoderRXingResult, ECIStringBuilder, Result},
Exceptions,
};
@@ -727,12 +727,7 @@ fn decodeBase256Segment(
*byte = unrandomize255State(bits.readBits(8)?, codewordPosition) as u8;
codewordPosition += 1;
}
result.append_string(
&CharacterSetECI::ISO8859_1
.decode(&bytes)
?,
);
result.append_string(&CharacterSetECI::ISO8859_1.decode(&bytes)?);
byteSegments.push(bytes);
Ok(())

View File

@@ -16,7 +16,7 @@
use std::rc::Rc;
use crate::common::{Result, CharacterSetECI};
use crate::common::{CharacterSetECI, Result};
use crate::{Dimension, Exceptions};
use super::{SymbolInfo, SymbolInfoLookup, SymbolShapeHint};
@@ -57,14 +57,10 @@ impl<'a> EncoderContext<'_> {
// }
// sb.append(ch);
// }
let sb = if let Ok(encoded_bytes) =
ISO_8859_1_ENCODER.encode(msg)
{
ISO_8859_1_ENCODER
.decode(&encoded_bytes)
.map_err(|e| {
Exceptions::parse_with(format!("round trip decode should always work: {e}"))
})?
let sb = if let Ok(encoded_bytes) = ISO_8859_1_ENCODER.encode(msg) {
ISO_8859_1_ENCODER.decode(&encoded_bytes).map_err(|e| {
Exceptions::parse_with(format!("round trip decode should always work: {e}"))
})?
} else {
return Err(Exceptions::illegal_argument_with(
"Message contains characters outside ISO-8859-1 encoding.",

View File

@@ -18,7 +18,10 @@ use std::rc::Rc;
use once_cell::sync::Lazy;
use crate::{datamatrix::encoder::{SymbolInfo, SymbolShapeHint}, common::CharacterSetECI};
use crate::{
common::CharacterSetECI,
datamatrix::encoder::{SymbolInfo, SymbolShapeHint},
};
use super::{high_level_encoder, minimal_encoder, symbol_info, SymbolInfoLookup};

View File

@@ -16,7 +16,7 @@
use std::rc::Rc;
use crate::common::{Result, CharacterSetECI};
use crate::common::{CharacterSetECI, Result};
use crate::{Dimension, Exceptions};
use super::{

View File

@@ -17,7 +17,7 @@
use std::{fmt, rc::Rc};
use crate::{
common::{ECIInput, MinimalECIInput, Result, CharacterSetECI},
common::{CharacterSetECI, ECIInput, MinimalECIInput, Result},
Exceptions,
};
@@ -171,10 +171,7 @@ pub fn encodeHighLevelWithDetails(
msg = &msg[high_level_encoder::MACRO_06_HEADER.chars().count()..(msg.chars().count() - 2)];
}
Ok(ISO_8859_1_ENCODER
.decode(
&encode(msg, priorityCharset, fnc1, shape, macroId)?
)
.decode(&encode(msg, priorityCharset, fnc1, shape, macroId)?)
.expect("should decode"))
// return new String(encode(msg, priorityCharset, fnc1, shape, macroId), StandardCharsets.ISO_8859_1);
}