mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
rename helper methods
This commit is contained in:
@@ -53,7 +53,7 @@ pub const WORD_SIZE: [u32; 33] = [
|
||||
pub fn encode_simple(data: &str) -> Result<AztecCode, Exceptions> {
|
||||
let Ok(bytes) = encoding::all::ISO_8859_1
|
||||
.encode(data, encoding::EncoderTrap::Replace) else {
|
||||
return Err(Exceptions::illegalArgument(format!("'{data}' cannot be encoded as ISO_8859_1")));
|
||||
return Err(Exceptions::illegalArgumentWith(format!("'{data}' cannot be encoded as ISO_8859_1")));
|
||||
};
|
||||
encode_bytes_simple(&bytes)
|
||||
}
|
||||
@@ -75,7 +75,7 @@ pub fn encode(
|
||||
if let Ok(bytes) = encoding::all::ISO_8859_1.encode(data, encoding::EncoderTrap::Strict) {
|
||||
encode_bytes(&bytes, minECCPercent, userSpecifiedLayers)
|
||||
} else {
|
||||
Err(Exceptions::illegalArgument(format!(
|
||||
Err(Exceptions::illegalArgumentWith(format!(
|
||||
"'{data}' cannot be encoded as ISO_8859_1"
|
||||
)))
|
||||
}
|
||||
@@ -102,7 +102,7 @@ pub fn encode_with_charset(
|
||||
if let Ok(bytes) = charset.encode(data, encoding::EncoderTrap::Strict) {
|
||||
encode_bytes_with_charset(&bytes, minECCPercent, userSpecifiedLayers, charset)
|
||||
} else {
|
||||
Err(Exceptions::illegalArgument(format!(
|
||||
Err(Exceptions::illegalArgumentWith(format!(
|
||||
"'{data}' cannot be encoded as ISO_8859_1"
|
||||
)))
|
||||
}
|
||||
@@ -178,7 +178,7 @@ pub fn encode_bytes_with_charset(
|
||||
MAX_NB_BITS
|
||||
})
|
||||
{
|
||||
return Err(Exceptions::illegalArgument(format!(
|
||||
return Err(Exceptions::illegalArgumentWith(format!(
|
||||
"Illegal value {user_specified_layers} for layers"
|
||||
)));
|
||||
}
|
||||
@@ -187,13 +187,13 @@ pub fn encode_bytes_with_charset(
|
||||
let usable_bits_in_layers = total_bits_in_layer_var - (total_bits_in_layer_var % word_size);
|
||||
stuffed_bits = stuffBits(&bits, word_size as usize)?;
|
||||
if stuffed_bits.getSize() as u32 + ecc_bits > usable_bits_in_layers {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
return Err(Exceptions::illegalArgumentWith(
|
||||
"Data to large for user specified layer",
|
||||
));
|
||||
}
|
||||
if compact && stuffed_bits.getSize() as u32 > word_size * 64 {
|
||||
// Compact format only allows 64 data words, though C4 can hold more words than that
|
||||
return Err(Exceptions::illegalArgument(
|
||||
return Err(Exceptions::illegalArgumentWith(
|
||||
"Data to large for user specified layer",
|
||||
));
|
||||
}
|
||||
@@ -207,7 +207,7 @@ pub fn encode_bytes_with_charset(
|
||||
loop {
|
||||
// for (int i = 0; ; i++) {
|
||||
if i > MAX_NB_BITS {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
return Err(Exceptions::illegalArgumentWith(
|
||||
"Data too large for an Aztec code",
|
||||
));
|
||||
}
|
||||
@@ -482,7 +482,7 @@ fn getGF(wordSize: usize) -> Result<GenericGFRef, Exceptions> {
|
||||
8 => Ok(get_predefined_genericgf(PredefinedGenericGF::AztecData8)),
|
||||
10 => Ok(get_predefined_genericgf(PredefinedGenericGF::AztecData10)),
|
||||
12 => Ok(get_predefined_genericgf(PredefinedGenericGF::AztecData12)),
|
||||
_ => Err(Exceptions::illegalArgument(format!(
|
||||
_ => Err(Exceptions::illegalArgumentWith(format!(
|
||||
"Unsupported word size {wordSize}"
|
||||
))),
|
||||
}
|
||||
|
||||
@@ -248,7 +248,9 @@ impl HighLevelEncoder {
|
||||
initial_state = initial_state.appendFLGn(CharacterSetECI::getValue(&eci))?;
|
||||
}
|
||||
} else {
|
||||
return Err(Exceptions::illegalArgument("No ECI code for character set"));
|
||||
return Err(Exceptions::illegalArgumentWith(
|
||||
"No ECI code for character set",
|
||||
));
|
||||
}
|
||||
// if self.charset != null {
|
||||
// CharacterSetECI eci = CharacterSetECI.getCharacterSetECI(charset);
|
||||
|
||||
@@ -80,7 +80,7 @@ impl State {
|
||||
token.add(0, 3); // 0: FNC1
|
||||
} else */
|
||||
if eci > 999999 {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
return Err(Exceptions::illegalArgumentWith(
|
||||
"ECI code must be between 0 and 999999",
|
||||
));
|
||||
// throw new IllegalArgumentException("ECI code must be between 0 and 999999");
|
||||
@@ -88,7 +88,7 @@ impl State {
|
||||
let Ok(eci_digits) = encoding::all::ISO_8859_1
|
||||
.encode(&format!("{eci}"), encoding::EncoderTrap::Strict)
|
||||
else {
|
||||
return Err(Exceptions::illegalArgumentEmpty())
|
||||
return Err(Exceptions::illegalArgument)
|
||||
};
|
||||
// let eciDigits = Integer.toString(eci).getBytes(StandardCharsets.ISO_8859_1);
|
||||
token.add(eci_digits.len() as i32, 3); // 1-6: number of ECI digits
|
||||
|
||||
@@ -31,7 +31,7 @@ impl TokenType {
|
||||
match self {
|
||||
TokenType::Simple(a) => a.appendTo(bit_array, text),
|
||||
TokenType::BinaryShift(a) => a.appendTo(bit_array, text),
|
||||
TokenType::Empty => Err(Exceptions::illegalState(
|
||||
TokenType::Empty => Err(Exceptions::illegalStateWith(
|
||||
"cannot appendTo on Empty final item",
|
||||
)),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user