diff --git a/src/common/character_set_eci.rs b/src/common/character_set_eci.rs index e357d9d..1360ace 100644 --- a/src/common/character_set_eci.rs +++ b/src/common/character_set_eci.rs @@ -36,19 +36,19 @@ use crate::Exceptions; #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum CharacterSetECI { // Enum name is a Java encoding valid for java.lang and java.io - Cp437, //(new int[]{0,2}), - ISO8859_1, //(new int[]{1,3}, "ISO-8859-1"), - ISO8859_2, //(4, "ISO-8859-2"), - ISO8859_3, //(5, "ISO-8859-3"), - ISO8859_4, //(6, "ISO-8859-4"), - ISO8859_5, //(7, "ISO-8859-5"), + Cp437, //(new int[]{0,2}), + ISO8859_1, //(new int[]{1,3}, "ISO-8859-1"), + ISO8859_2, //(4, "ISO-8859-2"), + ISO8859_3, //(5, "ISO-8859-3"), + ISO8859_4, //(6, "ISO-8859-4"), + ISO8859_5, //(7, "ISO-8859-5"), //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_9, //(11, "ISO-8859-9"), + ISO8859_9, //(11, "ISO-8859-9"), // ISO8859_10, //(12, "ISO-8859-10"), // 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_15, //(17, "ISO-8859-15"), ISO8859_16, //(18, "ISO-8859-16"), diff --git a/src/common/minimal_eci_input.rs b/src/common/minimal_eci_input.rs index 5239620..f52dd14 100644 --- a/src/common/minimal_eci_input.rs +++ b/src/common/minimal_eci_input.rs @@ -283,13 +283,14 @@ impl MinimalECIInput { let mut start = 0; let mut end = encoderSet.len(); //if let Some(fnc1) = fnc1 { - if encoderSet.getPriorityEncoderIndex().is_some() - && (( fnc1.is_some() && 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; - } + if encoderSet.getPriorityEncoderIndex().is_some() + && ((fnc1.is_some() + && 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; + } //} for i in start..end { diff --git a/src/datamatrix/encoder/c40_encoder.rs b/src/datamatrix/encoder/c40_encoder.rs index de44215..5fe84ec 100644 --- a/src/datamatrix/encoder/c40_encoder.rs +++ b/src/datamatrix/encoder/c40_encoder.rs @@ -26,7 +26,12 @@ pub struct C40Encoder; impl Encoder for C40Encoder { 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 { diff --git a/src/datamatrix/encoder/high_level_encode_test_case.rs b/src/datamatrix/encoder/high_level_encode_test_case.rs index cf3a317..96383d6 100644 --- a/src/datamatrix/encoder/high_level_encode_test_case.rs +++ b/src/datamatrix/encoder/high_level_encode_test_case.rs @@ -544,10 +544,12 @@ fn testPadding() { fn encodeHighLevelWithSizes(msg: &str, sizes: &mut [usize]) { sizes[0] = high_level_encoder::encodeHighLevel(msg) .expect("encodes") - .chars().count(); + .chars() + .count(); sizes[1] = minimal_encoder::encodeHighLevel(msg) .expect("encodes") - .chars().count(); + .chars() + .count(); } fn encodeHighLevel(msg: &str) -> String { @@ -557,7 +559,12 @@ fn encodeHighLevel(msg: &str) -> String { fn encodeHighLevelCompare(msg: &str, compareSizeToMinimalEncoder: bool) -> String { let encoded = high_level_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) } diff --git a/src/datamatrix/encoder/minimal_encoder.rs b/src/datamatrix/encoder/minimal_encoder.rs index 11872c1..5828b60 100755 --- a/src/datamatrix/encoder/minimal_encoder.rs +++ b/src/datamatrix/encoder/minimal_encoder.rs @@ -1302,7 +1302,8 @@ impl RXingResult { size += Self::prepend(&Edge::getBytes1(254), &mut bytesAL); } 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(¤t.getDataBytes()?, &mut bytesAL); if current.previous.is_none() diff --git a/src/datamatrix/encoder/mod.rs b/src/datamatrix/encoder/mod.rs index 094a7ce..da25586 100644 --- a/src/datamatrix/encoder/mod.rs +++ b/src/datamatrix/encoder/mod.rs @@ -1,10 +1,10 @@ mod encoder; mod encoder_context; +pub mod error_correction; pub mod high_level_encoder; pub mod minimal_encoder; mod symbol_info; mod symbol_shape_hint; -pub mod error_correction; pub use encoder::*; pub use encoder_context::*; diff --git a/src/datamatrix/encoder/text_encoder.rs b/src/datamatrix/encoder/text_encoder.rs index 61d75fc..4de6992 100644 --- a/src/datamatrix/encoder/text_encoder.rs +++ b/src/datamatrix/encoder/text_encoder.rs @@ -23,8 +23,12 @@ impl Encoder for TextEncoder { } fn encode(&self, context: &mut super::EncoderContext) -> Result<(), crate::Exceptions> { - self.0 - .encode_with_encode_char_fn(context, &Self::encodeChar, &C40Encoder::handleEOD_c40, &||{self.getEncodingMode()}) + self.0.encode_with_encode_char_fn( + context, + &Self::encodeChar, + &C40Encoder::handleEOD_c40, + &|| self.getEncodingMode(), + ) } } impl TextEncoder {