mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
cargo fmt
This commit is contained in:
@@ -50,7 +50,9 @@ impl BinaryShiftToken {
|
||||
bit_array.appendBits(bsbc as u32 - 31, 5).unwrap();
|
||||
}
|
||||
}
|
||||
bit_array.appendBits(text[self.binary_shift_start as usize + i].into(), 8).expect("should never fail to append");
|
||||
bit_array
|
||||
.appendBits(text[self.binary_shift_start as usize + i].into(), 8)
|
||||
.expect("should never fail to append");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ use encoding::Encoding;
|
||||
use crate::{
|
||||
common::{
|
||||
reedsolomon::{
|
||||
get_predefined_genericgf, PredefinedGenericGF, ReedSolomonEncoder, GenericGFRef,
|
||||
get_predefined_genericgf, GenericGFRef, PredefinedGenericGF, ReedSolomonEncoder,
|
||||
},
|
||||
BitArray, BitMatrix,
|
||||
},
|
||||
@@ -157,7 +157,7 @@ pub fn encode_bytes_with_charset(
|
||||
let ecc_bits = bits.getSize() as u32 * min_eccpercent / 100 + 11;
|
||||
let total_size_bits = bits.getSize() as u32 + ecc_bits;
|
||||
let mut compact;
|
||||
let mut layers:u32;
|
||||
let mut layers: u32;
|
||||
let mut total_bits_in_layer_var;
|
||||
let mut word_size;
|
||||
let mut stuffed_bits;
|
||||
|
||||
@@ -127,8 +127,8 @@ impl HighLevelEncoder {
|
||||
char_map[Self::MODE_DIGIT][b'.' as usize] = 13;
|
||||
let mixed_table = [
|
||||
'\0', ' ', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}',
|
||||
'\t', '\n', '\u{000b}', '\u{000c}', '\r', '\u{001b}', '\u{001c}', '\u{001d}', '\u{001e}', '\u{001f}',
|
||||
'@', '\\', '^', '_', '`', '|', '~', '\u{007f}',
|
||||
'\t', '\n', '\u{000b}', '\u{000c}', '\r', '\u{001b}', '\u{001c}', '\u{001d}',
|
||||
'\u{001e}', '\u{001f}', '@', '\\', '^', '_', '`', '|', '~', '\u{007f}',
|
||||
];
|
||||
let mut i = 0;
|
||||
while i < mixed_table.len() {
|
||||
@@ -245,7 +245,8 @@ impl HighLevelEncoder {
|
||||
pub fn encode(&self) -> Result<BitArray, Exceptions> {
|
||||
let mut initial_state = State::new(Token::new(), Self::MODE_UPPER as u32, 0, 0);
|
||||
if let Some(eci) = CharacterSetECI::getCharacterSetECI(self.charset) {
|
||||
if eci != CharacterSetECI::ISO8859_1 {//} && eci != CharacterSetECI::Cp1252 {
|
||||
if eci != CharacterSetECI::ISO8859_1 {
|
||||
//} && eci != CharacterSetECI::Cp1252 {
|
||||
initial_state = initial_state.appendFLGn(CharacterSetECI::getValue(&eci))?;
|
||||
}
|
||||
} else {
|
||||
@@ -278,7 +279,7 @@ impl HighLevelEncoder {
|
||||
b':' if next_char == b' ' => 5,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
|
||||
if pair_code > 0 {
|
||||
// We have one of the four special PUNCT pairs. Treat them specially.
|
||||
// Get a new set of states for the two new characters.
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
mod aztec_code;
|
||||
mod token;
|
||||
mod simple_token;
|
||||
mod binary_shift_token;
|
||||
mod state;
|
||||
mod high_level_encoder;
|
||||
mod simple_token;
|
||||
mod state;
|
||||
mod token;
|
||||
|
||||
pub mod encoder;
|
||||
|
||||
pub use aztec_code::*;
|
||||
pub use token::*;
|
||||
pub use simple_token::*;
|
||||
pub use binary_shift_token::*;
|
||||
pub use high_level_encoder::*;
|
||||
pub use simple_token::*;
|
||||
pub use state::*;
|
||||
pub use high_level_encoder::*;
|
||||
pub use token::*;
|
||||
|
||||
@@ -78,7 +78,8 @@ impl State {
|
||||
let mut bits_added = 3;
|
||||
/*if eci < 0 {
|
||||
token.add(0, 3); // 0: FNC1
|
||||
} else */if eci > 999999 {
|
||||
} else */
|
||||
if eci > 999999 {
|
||||
return Err(Exceptions::IllegalArgumentException(
|
||||
"ECI code must be between 0 and 999999".to_owned(),
|
||||
));
|
||||
@@ -151,15 +152,16 @@ impl State {
|
||||
bitCount += latch >> 16;
|
||||
mode = HighLevelEncoder::MODE_UPPER as u32;
|
||||
}
|
||||
let deltaBitCount = if self.binary_shift_byte_count == 0 || self.binary_shift_byte_count == 31 {
|
||||
18
|
||||
} else {
|
||||
if self.binary_shift_byte_count == 62 {
|
||||
9
|
||||
let deltaBitCount =
|
||||
if self.binary_shift_byte_count == 0 || self.binary_shift_byte_count == 31 {
|
||||
18
|
||||
} else {
|
||||
8
|
||||
}
|
||||
};
|
||||
if self.binary_shift_byte_count == 62 {
|
||||
9
|
||||
} else {
|
||||
8
|
||||
}
|
||||
};
|
||||
let mut result = State::new(
|
||||
token,
|
||||
mode,
|
||||
@@ -180,7 +182,10 @@ impl State {
|
||||
return self;
|
||||
}
|
||||
let mut token = self.token;
|
||||
token.addBinaryShift(index - self.binary_shift_byte_count, self.binary_shift_byte_count);
|
||||
token.addBinaryShift(
|
||||
index - self.binary_shift_byte_count,
|
||||
self.binary_shift_byte_count,
|
||||
);
|
||||
|
||||
State::new(token, self.mode, 0, self.bit_count)
|
||||
}
|
||||
@@ -218,7 +223,7 @@ impl State {
|
||||
let mut bit_array = BitArray::new();
|
||||
// Add each token to the result in forward order
|
||||
for symbol in symbols.into_iter().rev() {
|
||||
// for i in (0..symbols.len()).rev() {
|
||||
// for i in (0..symbols.len()).rev() {
|
||||
// for (int i = symbols.size() - 1; i >= 0; i--) {
|
||||
symbol.appendTo(&mut bit_array, text);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ impl TokenType {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Token {
|
||||
tokens: Vec<TokenType>,
|
||||
//current_pointer: usize,
|
||||
@@ -53,13 +53,13 @@ impl Token {
|
||||
// self.current_pointer -= 1;
|
||||
// &self.tokens[self.current_pointer]
|
||||
// }
|
||||
pub fn add(&mut self, value: i32, bit_count: u32) {
|
||||
pub fn add(&mut self, value: i32, bit_count: u32) {
|
||||
//self.current_pointer += 1;
|
||||
self.tokens
|
||||
.push(TokenType::Simple(SimpleToken::new(value, bit_count)));
|
||||
// &self.tokens[self.current_pointer]
|
||||
}
|
||||
pub fn addBinaryShift(&mut self, start: u32, byte_count: u32) {
|
||||
pub fn addBinaryShift(&mut self, start: u32, byte_count: u32) {
|
||||
//self.current_pointer += 1;
|
||||
self.tokens
|
||||
.push(TokenType::BinaryShift(BinaryShiftToken::new(
|
||||
@@ -78,7 +78,7 @@ impl Iterator for TokenIter {
|
||||
type Item = TokenType;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
self.src.pop()
|
||||
self.src.pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user