mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
chore: various cleanups, version bump 0.4.12
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rxing"
|
name = "rxing"
|
||||||
version = "0.4.11"
|
version = "0.4.12"
|
||||||
description="A rust port of the zxing barcode library."
|
description="A rust port of the zxing barcode library."
|
||||||
license="Apache-2.0"
|
license="Apache-2.0"
|
||||||
repository="https://github.com/rxing-core/rxing"
|
repository="https://github.com/rxing-core/rxing"
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ pub fn matchSingleVCardPrefixedField(
|
|||||||
if values.is_empty() {
|
if values.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(values.get(0)?.clone())
|
Some(values.first()?.clone())
|
||||||
// return values == null || values.isEmpty() ? null : values.get(0);
|
// return values == null || values.isEmpty() ? null : values.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,7 +437,7 @@ fn toPrimaryValue(list: Option<Vec<String>>) -> String {
|
|||||||
if l.is_empty() {
|
if l.is_empty() {
|
||||||
String::default()
|
String::default()
|
||||||
} else {
|
} else {
|
||||||
l.get(0).unwrap_or(&String::default()).clone()
|
l.first().unwrap_or(&String::default()).clone()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String::default()
|
String::default()
|
||||||
@@ -471,7 +471,7 @@ fn toTypes(lists: Option<Vec<Vec<String>>>) -> Vec<String> {
|
|||||||
let mut result = Vec::with_capacity(local_lists.len()); //new ArrayList<>(lists.size());
|
let mut result = Vec::with_capacity(local_lists.len()); //new ArrayList<>(lists.size());
|
||||||
for list in local_lists {
|
for list in local_lists {
|
||||||
// for (List<String> list : lists) {
|
// for (List<String> list : lists) {
|
||||||
if let Some(value) = list.get(0) {
|
if let Some(value) = list.first() {
|
||||||
if !value.is_empty() {
|
if !value.is_empty() {
|
||||||
let mut v_type = String::new();
|
let mut v_type = String::new();
|
||||||
let final_value = list.last().unwrap_or(&String::default()).clone();
|
let final_value = list.last().unwrap_or(&String::default()).clone();
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ fn matchVCardPrefixedField(prefix: &str, rawText: &str) -> Vec<String> {
|
|||||||
for (i, res) in result.iter_mut().enumerate().take(size) {
|
for (i, res) in result.iter_mut().enumerate().take(size) {
|
||||||
// for i in 0..size {
|
// for i in 0..size {
|
||||||
// for (int i = 0; i < size; i++) {
|
// for (int i = 0; i < size; i++) {
|
||||||
*res = values.get(i).unwrap().get(0).unwrap().clone();
|
*res = values.get(i).unwrap().first().unwrap().clone();
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ struct InputEdge {
|
|||||||
cachedTotalSize: usize,
|
cachedTotalSize: usize,
|
||||||
}
|
}
|
||||||
impl InputEdge {
|
impl InputEdge {
|
||||||
const FNC1_UNICODE: &str = "\u{1000}";
|
const FNC1_UNICODE: &'static str = "\u{1000}";
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
c: &str,
|
c: &str,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ pub fn get_predefined_genericgf(request: PredefinedGenericGF) -> GenericGFRef {
|
|||||||
PredefinedGenericGF::DataMatrixField256 | PredefinedGenericGF::AztecData8 => {
|
PredefinedGenericGF::DataMatrixField256 | PredefinedGenericGF::AztecData8 => {
|
||||||
&DATA_MATRIX_FIELD_256
|
&DATA_MATRIX_FIELD_256
|
||||||
} // x^8 + x^5 + x^3 + x^2 + 1
|
} // x^8 + x^5 + x^3 + x^2 + 1
|
||||||
// PredefinedGenericGF::PDF417 => &PDF_417_FIELD,
|
// PredefinedGenericGF::PDF417 => &PDF_417_FIELD,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ impl OneDReader for Code39Reader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl Code39Reader {
|
impl Code39Reader {
|
||||||
pub const ALPHABET_STRING: &str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%";
|
pub const ALPHABET_STRING: &'static str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These represent the encodings of characters, as patterns of wide and narrow bars.
|
* These represent the encodings of characters, as patterns of wide and narrow bars.
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ impl OneDReader for Code93Reader {
|
|||||||
|
|
||||||
impl Code93Reader {
|
impl Code93Reader {
|
||||||
// Note that 'abcd' are dummy characters in place of control characters.
|
// Note that 'abcd' are dummy characters in place of control characters.
|
||||||
pub const ALPHABET_STRING: &str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*";
|
pub const ALPHABET_STRING: &'static str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*";
|
||||||
pub const ALPHABET: [char; 48] = [
|
pub const ALPHABET: [char; 48] = [
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||||
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ pub fn buildBitArray(pairs: &Vec<ExpandedPair>) -> Option<BitArray> {
|
|||||||
let mut binary = BitArray::with_size(size);
|
let mut binary = BitArray::with_size(size);
|
||||||
let mut accPos = 0;
|
let mut accPos = 0;
|
||||||
|
|
||||||
let firstPair = pairs.get(0)?;
|
let firstPair = pairs.first()?;
|
||||||
let rp = firstPair.getRightChar().as_ref()?;
|
let rp = firstPair.getRightChar().as_ref()?;
|
||||||
let firstValue = rp.getValue();
|
let firstValue = rp.getValue();
|
||||||
let mut i = 11;
|
let mut i = 11;
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ impl RSSExpandedReader {
|
|||||||
let resultingString = decoder.parseInformation()?;
|
let resultingString = decoder.parseInformation()?;
|
||||||
|
|
||||||
let firstPoints = pairs
|
let firstPoints = pairs
|
||||||
.get(0)
|
.first()
|
||||||
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?
|
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS)?
|
||||||
.getFinderPattern()
|
.getFinderPattern()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@@ -565,7 +565,7 @@ impl RSSExpandedReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn checkChecksum(&self) -> bool {
|
fn checkChecksum(&self) -> bool {
|
||||||
let Some(firstPair) = self.pairs.get(0) else {
|
let Some(firstPair) = self.pairs.first() else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
let checkCharacter = firstPair.getLeftChar();
|
let checkCharacter = firstPair.getLeftChar();
|
||||||
|
|||||||
@@ -123,8 +123,7 @@ pub fn ReadQRCodewords(
|
|||||||
) -> Result<Vec<u8>> {
|
) -> Result<Vec<u8>> {
|
||||||
let functionPattern: BitMatrix = version.buildFunctionPattern()?;
|
let functionPattern: BitMatrix = version.buildFunctionPattern()?;
|
||||||
|
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::with_capacity(version.getTotalCodewords() as usize);
|
||||||
result.reserve(version.getTotalCodewords() as usize);
|
|
||||||
let mut currentByte = 0;
|
let mut currentByte = 0;
|
||||||
let mut readingUp = true;
|
let mut readingUp = true;
|
||||||
let mut bitsRead = 0;
|
let mut bitsRead = 0;
|
||||||
@@ -190,8 +189,7 @@ pub fn ReadMQRCodewords(
|
|||||||
9
|
9
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::with_capacity(version.getTotalCodewords() as usize);
|
||||||
result.reserve(version.getTotalCodewords() as usize);
|
|
||||||
let mut currentByte = 0;
|
let mut currentByte = 0;
|
||||||
let mut readingUp = true;
|
let mut readingUp = true;
|
||||||
let mut bitsRead = 0;
|
let mut bitsRead = 0;
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ impl AlignmentPatternFinder {
|
|||||||
if !self.possibleCenters.is_empty() {
|
if !self.possibleCenters.is_empty() {
|
||||||
Ok(*(self
|
Ok(*(self
|
||||||
.possibleCenters
|
.possibleCenters
|
||||||
.get(0)
|
.first()
|
||||||
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS))?)
|
.ok_or(Exceptions::INDEX_OUT_OF_BOUNDS))?)
|
||||||
} else {
|
} else {
|
||||||
Err(Exceptions::NOT_FOUND)
|
Err(Exceptions::NOT_FOUND)
|
||||||
|
|||||||
@@ -754,7 +754,7 @@ impl RXingResultList {
|
|||||||
// prepend FNC1 if needed. If the bits contain an ECI then the FNC1 must be preceeded by an ECI.
|
// prepend FNC1 if needed. If the bits contain an ECI then the FNC1 must be preceeded by an ECI.
|
||||||
// If there is no ECI at the beginning then we put an ECI to the default charset (ISO-8859-1)
|
// If there is no ECI at the beginning then we put an ECI to the default charset (ISO-8859-1)
|
||||||
if isGS1 {
|
if isGS1 {
|
||||||
if let Some(first) = list.get(0) {
|
if let Some(first) = list.first() {
|
||||||
if first.mode != Mode::ECI && containsECI {
|
if first.mode != Mode::ECI && containsECI {
|
||||||
// prepend a default character set ECI
|
// prepend a default character set ECI
|
||||||
list.push(RXingResultNode::new(
|
list.push(RXingResultNode::new(
|
||||||
@@ -769,7 +769,7 @@ impl RXingResultList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(first) = list.get(0) {
|
if let Some(first) = list.first() {
|
||||||
// prepend or insert a FNC1_FIRST_POSITION after the ECI (if any)
|
// prepend or insert a FNC1_FIRST_POSITION after the ECI (if any)
|
||||||
if first.mode != Mode::ECI {
|
if first.mode != Mode::ECI {
|
||||||
//&& containsECI {
|
//&& containsECI {
|
||||||
|
|||||||
Reference in New Issue
Block a user