mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
cargo fmt
This commit is contained in:
@@ -284,7 +284,8 @@ impl MinimalECIInput {
|
|||||||
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()
|
||||||
|
&& ch.chars().nth(0).unwrap() == fnc1.as_ref().unwrap().chars().nth(0).unwrap())
|
||||||
|| encoderSet.canEncode(ch, encoderSet.getPriorityEncoderIndex().unwrap()))
|
|| encoderSet.canEncode(ch, encoderSet.getPriorityEncoderIndex().unwrap()))
|
||||||
{
|
{
|
||||||
start = encoderSet.getPriorityEncoderIndex().unwrap();
|
start = encoderSet.getPriorityEncoderIndex().unwrap();
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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(¤t.getDataBytes()?, &mut bytesAL);
|
size += Self::prepend(¤t.getDataBytes()?, &mut bytesAL);
|
||||||
|
|
||||||
if current.previous.is_none()
|
if current.previous.is_none()
|
||||||
|
|||||||
@@ -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::*;
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user