cargo fmt

This commit is contained in:
Henry Schimke
2022-11-05 16:38:51 -05:00
parent 5d906edbde
commit 5e1f4c7011
7 changed files with 42 additions and 24 deletions

View File

@@ -36,19 +36,19 @@ use crate::Exceptions;
#[derive(Debug, PartialEq, Eq, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum CharacterSetECI { pub enum CharacterSetECI {
// Enum name is a Java encoding valid for java.lang and java.io // Enum name is a Java encoding valid for java.lang and java.io
Cp437, //(new int[]{0,2}), Cp437, //(new int[]{0,2}),
ISO8859_1, //(new int[]{1,3}, "ISO-8859-1"), ISO8859_1, //(new int[]{1,3}, "ISO-8859-1"),
ISO8859_2, //(4, "ISO-8859-2"), ISO8859_2, //(4, "ISO-8859-2"),
ISO8859_3, //(5, "ISO-8859-3"), ISO8859_3, //(5, "ISO-8859-3"),
ISO8859_4, //(6, "ISO-8859-4"), ISO8859_4, //(6, "ISO-8859-4"),
ISO8859_5, //(7, "ISO-8859-5"), ISO8859_5, //(7, "ISO-8859-5"),
//ISO8859_6, //(8, "ISO-8859-6"), //ISO8859_6, //(8, "ISO-8859-6"),
ISO8859_7, //(9, "ISO-8859-7"), ISO8859_7, //(9, "ISO-8859-7"),
//ISO8859_8, //(10, "ISO-8859-8"), //ISO8859_8, //(10, "ISO-8859-8"),
ISO8859_9, //(11, "ISO-8859-9"), ISO8859_9, //(11, "ISO-8859-9"),
// ISO8859_10, //(12, "ISO-8859-10"), // ISO8859_10, //(12, "ISO-8859-10"),
// ISO8859_11, //(13, "ISO-8859-11"), // ISO8859_11, //(13, "ISO-8859-11"),
ISO8859_13, //(15, "ISO-8859-13"), ISO8859_13, //(15, "ISO-8859-13"),
// ISO8859_14, //(16, "ISO-8859-14"), // ISO8859_14, //(16, "ISO-8859-14"),
ISO8859_15, //(17, "ISO-8859-15"), ISO8859_15, //(17, "ISO-8859-15"),
ISO8859_16, //(18, "ISO-8859-16"), ISO8859_16, //(18, "ISO-8859-16"),

View File

@@ -283,13 +283,14 @@ impl MinimalECIInput {
let mut start = 0; let mut start = 0;
let mut end = encoderSet.len(); let mut end = encoderSet.len();
//if let Some(fnc1) = fnc1 { //if let Some(fnc1) = fnc1 {
if encoderSet.getPriorityEncoderIndex().is_some() if encoderSet.getPriorityEncoderIndex().is_some()
&& (( fnc1.is_some() && ch.chars().nth(0).unwrap() == fnc1.as_ref().unwrap().chars().nth(0).unwrap()) && ((fnc1.is_some()
|| encoderSet.canEncode(ch, encoderSet.getPriorityEncoderIndex().unwrap())) && ch.chars().nth(0).unwrap() == fnc1.as_ref().unwrap().chars().nth(0).unwrap())
{ || encoderSet.canEncode(ch, encoderSet.getPriorityEncoderIndex().unwrap()))
start = encoderSet.getPriorityEncoderIndex().unwrap(); {
end = start + 1; start = encoderSet.getPriorityEncoderIndex().unwrap();
} end = start + 1;
}
//} //}
for i in start..end { for i in start..end {

View File

@@ -26,7 +26,12 @@ pub struct C40Encoder;
impl Encoder for C40Encoder { impl Encoder for C40Encoder {
fn encode(&self, context: &mut super::EncoderContext) -> Result<(), Exceptions> { fn encode(&self, context: &mut super::EncoderContext) -> Result<(), Exceptions> {
self.encode_with_encode_char_fn(context, &Self::encodeChar_c40, &Self::handleEOD_c40, &||{self.getEncodingMode()}) self.encode_with_encode_char_fn(
context,
&Self::encodeChar_c40,
&Self::handleEOD_c40,
&|| self.getEncodingMode(),
)
} }
fn getEncodingMode(&self) -> usize { fn getEncodingMode(&self) -> usize {

View File

@@ -544,10 +544,12 @@ fn testPadding() {
fn encodeHighLevelWithSizes(msg: &str, sizes: &mut [usize]) { fn encodeHighLevelWithSizes(msg: &str, sizes: &mut [usize]) {
sizes[0] = high_level_encoder::encodeHighLevel(msg) sizes[0] = high_level_encoder::encodeHighLevel(msg)
.expect("encodes") .expect("encodes")
.chars().count(); .chars()
.count();
sizes[1] = minimal_encoder::encodeHighLevel(msg) sizes[1] = minimal_encoder::encodeHighLevel(msg)
.expect("encodes") .expect("encodes")
.chars().count(); .chars()
.count();
} }
fn encodeHighLevel(msg: &str) -> String { fn encodeHighLevel(msg: &str) -> String {
@@ -557,7 +559,12 @@ fn encodeHighLevel(msg: &str) -> String {
fn encodeHighLevelCompare(msg: &str, compareSizeToMinimalEncoder: bool) -> String { fn encodeHighLevelCompare(msg: &str, compareSizeToMinimalEncoder: bool) -> String {
let encoded = high_level_encoder::encodeHighLevel(msg).expect("encodes"); let encoded = high_level_encoder::encodeHighLevel(msg).expect("encodes");
let encoded2 = minimal_encoder::encodeHighLevel(msg).expect("encodes"); let encoded2 = minimal_encoder::encodeHighLevel(msg).expect("encodes");
assert!(!compareSizeToMinimalEncoder || encoded2.chars().count() <= encoded.chars().count(), "{} <= {}", encoded2.chars().count() , encoded.chars().count()); assert!(
!compareSizeToMinimalEncoder || encoded2.chars().count() <= encoded.chars().count(),
"{} <= {}",
encoded2.chars().count(),
encoded.chars().count()
);
visualize(&encoded) visualize(&encoded)
} }

View File

@@ -1302,7 +1302,8 @@ impl RXingResult {
size += Self::prepend(&Edge::getBytes1(254), &mut bytesAL); size += Self::prepend(&Edge::getBytes1(254), &mut bytesAL);
} }
let mut hold_current = Some(solution.clone()); let mut hold_current = Some(solution.clone());
while let Some(current) = hold_current { // Fails on i = 77 should be 151 is 144 while let Some(current) = hold_current {
// Fails on i = 77 should be 151 is 144
size += Self::prepend(&current.getDataBytes()?, &mut bytesAL); size += Self::prepend(&current.getDataBytes()?, &mut bytesAL);
if current.previous.is_none() if current.previous.is_none()

View File

@@ -1,10 +1,10 @@
mod encoder; mod encoder;
mod encoder_context; mod encoder_context;
pub mod error_correction;
pub mod high_level_encoder; pub mod high_level_encoder;
pub mod minimal_encoder; pub mod minimal_encoder;
mod symbol_info; mod symbol_info;
mod symbol_shape_hint; mod symbol_shape_hint;
pub mod error_correction;
pub use encoder::*; pub use encoder::*;
pub use encoder_context::*; pub use encoder_context::*;

View File

@@ -23,8 +23,12 @@ impl Encoder for TextEncoder {
} }
fn encode(&self, context: &mut super::EncoderContext) -> Result<(), crate::Exceptions> { fn encode(&self, context: &mut super::EncoderContext) -> Result<(), crate::Exceptions> {
self.0 self.0.encode_with_encode_char_fn(
.encode_with_encode_char_fn(context, &Self::encodeChar, &C40Encoder::handleEOD_c40, &||{self.getEncodingMode()}) context,
&Self::encodeChar,
&C40Encoder::handleEOD_c40,
&|| self.getEncodingMode(),
)
} }
} }
impl TextEncoder { impl TextEncoder {