chore: version update and cargo fmt

This commit is contained in:
Henry Schimke
2024-01-02 17:10:56 -06:00
parent e04354cb4a
commit c3618919d7
10 changed files with 89 additions and 93 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "rxing"
version = "0.4.12"
version = "0.5.0"
description="A rust port of the zxing barcode library."
license="Apache-2.0"
repository="https://github.com/rxing-core/rxing"

View File

@@ -39,6 +39,7 @@ All barcode formats are tested and functioning in their current state against cu
| upc e | complete | yes | yes |
| rss-14 | complete | no | yes |
| rss-expanded | complete | no | yes|
| telepen | complete | yes | yes |
Please note that currently UPC/EAN Extension 2/5 is supported.
@@ -81,6 +82,13 @@ fn main() {
```
## Latest Release Notes
* *v0.5.0* -> Added support for [telepen](https://advanova.co.uk/wp-content/uploads/2022/05/Barcode-Symbology-information-and-History.pdf) thanks to the work of first time contributor [cpwood](https://github.com/cpwood).
This release also adds the ability to exclude building the "client" result parsing features. Currently part of the default
feature set, they can be disabled through the `client_support` feature.
This release fixes several build issues associated with the `chrono` crate and some deprecated function messages. This change
only impacts users building with the `client_support` feature.
* *v0.4.6* -> Fixed an issue with pdf417 whitespace, rotation, and compaction. Fix courtesy of first time contribution from GitHub user agkyunromb.
* *v0.4.4* -> Major update of QRCode support.

View File

@@ -7,8 +7,8 @@ use rxing::multi::{GenericMultipleBarcodeReader, MultipleBarcodeReader};
use rxing::oned::rss::expanded::RSSExpandedReader;
use rxing::oned::rss::RSS14Reader;
use rxing::oned::{
CodaBarReader, Code39Reader, Code93Reader, EAN13Reader, EAN8Reader, TelepenReader, ITFReader, UPCAReader,
UPCEReader,
CodaBarReader, Code39Reader, Code93Reader, EAN13Reader, EAN8Reader, ITFReader, TelepenReader,
UPCAReader, UPCEReader,
};
use rxing::pdf417::PDF417Reader;
use rxing::qrcode::QRCodeReader;

View File

@@ -11,4 +11,4 @@ keywords = ["barcode", "2d_barcode", "1d_barcode", "barcode_reader", "barcode_wr
[dependencies]
clap = { version = "4.2.0", features = ["derive"] }
rxing = {path = "../../", version = "~0.4.9", features = ["image", "svg_read", "svg_write"] }
rxing = {path = "../../", version = "~0.5.0", features = ["image", "svg_read", "svg_write"] }

View File

@@ -126,7 +126,6 @@ pub enum DecodeHintType {
* Will translate the ASCII values parsed by the Telepen reader into the Telepen Numeric form.
*/
TELEPEN_AS_NUMERIC,
/*
* Data type the hint is expecting.
* Among the possible values the {@link Void} stands out as being used for

View File

@@ -1,5 +1,5 @@
use crate::Exceptions;
use crate::common::Result;
use crate::Exceptions;
pub fn calculate_checksum(contents: &str) -> char {
let mut sum = 0;
@@ -12,8 +12,7 @@ pub fn calculate_checksum(contents: &str) -> char {
let diff = 127 - remainder;
return if diff != 127 {
diff as u8 as char
}
else {
} else {
0 as char
};
}
@@ -24,8 +23,7 @@ pub fn ascii_to_numeric(contents: &str) -> String {
for c in contents.chars().map(|x| x as u32) {
if c >= 27 {
number.push_str(&format!("{:0>2}", (c - 27)));
}
else {
} else {
number.push_str(&format!("{:0>2}", (c - 17)));
}
}
@@ -35,7 +33,9 @@ pub fn ascii_to_numeric(contents: &str) -> String {
pub fn numeric_to_ascii(contents: &str) -> Result<String> {
if contents.len() % 2 != 0 {
return Err(Exceptions::illegal_argument_with("Input must contain an even number of characters."));
return Err(Exceptions::illegal_argument_with(
"Input must contain an even number of characters.",
));
}
let mut ascii = String::new();
@@ -47,12 +47,13 @@ pub fn numeric_to_ascii(contents: &str) -> Result<String> {
if second == 88 && first >= 48 && first <= 57 {
ascii.push((17 + first - 48) as char);
}
else if second >= 48 && second <= 57 && first >= 48 && first <= 57 {
} else if second >= 48 && second <= 57 && first >= 48 && first <= 57 {
ascii.push((27 + (first - 48) * 10 + (second - 48)) as char);
}
else {
return Err(Exceptions::illegal_argument_with(format!("Input contains an invalid character around position {}.", i.to_string())));
} else {
return Err(Exceptions::illegal_argument_with(format!(
"Input contains an invalid character around position {}.",
i.to_string()
)));
}
i += 2;

View File

@@ -17,10 +17,10 @@
use rxing_one_d_proc_derive::OneDReader;
use crate::common::{BitArray, Result};
use crate::oned::telepen_common;
use crate::DecodeHintValue;
use crate::Exceptions;
use crate::RXingResult;
use crate::DecodeHintValue;
use crate::oned::telepen_common;
use crate::{point_f, BarcodeFormat};
use bit_reverse::ParallelReverse;
@@ -118,19 +118,15 @@ impl OneDReader for TelepenReader {
if isBlack {
// Narrow black: B
pattern[patternLength] = 1;
}
else {
} else {
// Narrow white: .
pattern[patternLength] = 0;
}
}
else {
} else {
if isBlack {
// Wide black: BBB
pattern[patternLength] = 3;
}
else {
} else {
// Wide white: ...
pattern[patternLength] = 2;
}
@@ -147,31 +143,26 @@ impl OneDReader for TelepenReader {
// Convert narrow-wide sequence into bit array.
while j < patternLength - 1 {
if pattern[j] == 3 && pattern[j + 1] == 2 {
// BBB... = 010
bits.appendBit(false);
bits.appendBit(true);
bits.appendBit(false);
}
else if pattern[j] == 3 && pattern[j + 1] == 0 {
} else if pattern[j] == 3 && pattern[j + 1] == 0 {
// BBB. = 00
bits.appendBit(false);
bits.appendBit(false);
}
else if pattern[j] == 1 && pattern[j + 1] == 2 && state == 0 {
} else if pattern[j] == 1 && pattern[j + 1] == 2 && state == 0 {
// B... = 01
bits.appendBit(false);
bits.appendBit(true);
state = 1;
}
else if pattern[j] == 1 && pattern[j + 1] == 2 && state == 1 {
} else if pattern[j] == 1 && pattern[j + 1] == 2 && state == 1 {
// B... = 10
bits.appendBit(true);
bits.appendBit(false);
state = 0;
}
else if pattern[j] == 1 && pattern[j + 1] == 0 {
} else if pattern[j] == 1 && pattern[j + 1] == 0 {
// B. = 1
bits.appendBit(true);
}
@@ -272,7 +263,6 @@ impl OneDReader for TelepenReader {
}
}
impl TelepenReader {
pub fn new() -> Self {
Self {
counters: vec![0; 80], //Vec::with_capacity(80),
@@ -302,12 +292,10 @@ impl TelepenReader {
while i < end {
if row.get(i) == currentColor {
count += 1;
}
else {
} else {
if count >= minToleratedWidth || self.counterLength == 0 {
self.counterAppend(count);
}
else {
} else {
// Noise from previous bar. Treat it as the
// previous colour.
self.counters[self.counterLength - 1] += count;
@@ -322,8 +310,7 @@ impl TelepenReader {
if count >= minToleratedWidth {
self.counterAppend(count);
}
else {
} else {
// Noise from previous bar. Treat it as the
// previous colour.
self.counters[self.counterLength - 1] += count;
@@ -380,8 +367,7 @@ impl TelepenReader {
if (self.counters[i + j] as f32) > median {
passed = false;
break;
}
else if j == 10 {
} else if j == 10 {
// Wide
if (self.counters[i + j] as f32) < median {
passed = false;

View File

@@ -14,11 +14,11 @@
* limitations under the License.
*/
use rxing_one_d_proc_derive::OneDWriter;
use regex::Regex;
use crate::common::Result;
use crate::BarcodeFormat;
use crate::oned::telepen_common;
use crate::BarcodeFormat;
use regex::Regex;
use rxing_one_d_proc_derive::OneDWriter;
use super::OneDimensionalCodeWriter;
@@ -35,9 +35,11 @@ impl OneDimensionalCodeWriter for TelepenWriter {
self.encode_oned_with_hints(contents, &HashMap::new())
}
fn encode_oned_with_hints(&self, contents: &str,
hints: &crate::EncodingHintDictionary) -> Result<Vec<bool>> {
fn encode_oned_with_hints(
&self,
contents: &str,
hints: &crate::EncodingHintDictionary,
) -> Result<Vec<bool>> {
let mut decodedContents = contents.to_string();
if matches!(
@@ -91,7 +93,7 @@ impl OneDimensionalCodeWriter for TelepenWriter {
result[resultPosition + 5] = false;
resultPosition += 6;
},
}
"00" => {
// BBB.
result[resultPosition] = true;
@@ -100,14 +102,14 @@ impl OneDimensionalCodeWriter for TelepenWriter {
result[resultPosition + 3] = false;
resultPosition += 4;
},
}
"1" => {
// B.
result[resultPosition] = true;
result[resultPosition + 1] = false;
resultPosition += 2;
},
}
"01" => {
// B...
result[resultPosition] = true;
@@ -116,7 +118,7 @@ impl OneDimensionalCodeWriter for TelepenWriter {
result[resultPosition + 3] = false;
resultPosition += 4;
},
}
"10" => {
// B...
result[resultPosition] = true;
@@ -125,12 +127,12 @@ impl OneDimensionalCodeWriter for TelepenWriter {
result[resultPosition + 3] = false;
resultPosition += 4;
},
}
"0" => {
return Err(Exceptions::illegal_argument_with(format!(
"Invalid bit combination!"
)));
},
}
_ => {
// B... (B.)* B...
result[resultPosition] = true;
@@ -191,12 +193,7 @@ impl TelepenWriter {
let bits = self.get_bits(byte);
for i in 0..8 {
binary.push(if bits[i] {
'1'
}
else {
'0'
});
binary.push(if bits[i] { '1' } else { '0' });
}
return binary;
@@ -212,7 +209,7 @@ mod TelepenWriterTestCase {
use crate::{
common::{bit_matrix_test_case, BitMatrix},
BarcodeFormat, Writer, EncodeHintType, EncodeHintValue,
BarcodeFormat, EncodeHintType, EncodeHintValue, Writer,
};
use super::TelepenWriter;
@@ -251,8 +248,7 @@ mod TelepenWriterTestCase {
if numeric {
result = encode_with_hints(input);
}
else {
} else {
result = encode(input);
};
@@ -267,7 +263,10 @@ mod TelepenWriterTestCase {
fn encode_with_hints(input: &str) -> BitMatrix {
let mut hints = HashMap::new();
hints.insert(EncodeHintType::TELEPEN_AS_NUMERIC, EncodeHintValue::TelepenAsNumeric(true));
hints.insert(
EncodeHintType::TELEPEN_AS_NUMERIC,
EncodeHintValue::TelepenAsNumeric(true),
);
TelepenWriter
.encode_with_hints(input, &BarcodeFormat::TELEPEN, 0, 0, &hints)

View File

@@ -46,7 +46,10 @@ fn telepen_numeric_test_case() {
);
tester.add_test_complex(7, 1, 0, 0, 0.0);
tester.add_hint(rxing::DecodeHintType::TELEPEN_AS_NUMERIC, rxing::DecodeHintValue::TelepenAsNumeric(true));
tester.add_hint(
rxing::DecodeHintType::TELEPEN_AS_NUMERIC,
rxing::DecodeHintValue::TelepenAsNumeric(true),
);
tester.ignore_pure = true;
tester.test_black_box();