mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
remove .to_owned() calls on &str in exceptions
This commit is contained in:
@@ -170,11 +170,7 @@ fn get_encoded_data(corrected_bits: &[bool]) -> Result<String, Exceptions> {
|
||||
decoded_bytes.clear();
|
||||
match n {
|
||||
0 => result.push(29 as char), // translate FNC1 as ASCII 29
|
||||
7 => {
|
||||
return Err(Exceptions::format(
|
||||
"FLG(7) is reserved and illegal".to_owned(),
|
||||
))
|
||||
} // FLG(7) is reserved and illegal
|
||||
7 => return Err(Exceptions::format("FLG(7) is reserved and illegal")), // FLG(7) is reserved and illegal
|
||||
_ => {
|
||||
// ECI is decimal integer encoded as 1-6 codes in DIGIT mode
|
||||
let mut eci = 0;
|
||||
@@ -186,7 +182,7 @@ fn get_encoded_data(corrected_bits: &[bool]) -> Result<String, Exceptions> {
|
||||
let next_digit = read_code(corrected_bits, index, 4);
|
||||
index += 4;
|
||||
if !(2..=11).contains(&next_digit) {
|
||||
return Err(Exceptions::format("Not a decimal digit".to_owned()));
|
||||
return Err(Exceptions::format("Not a decimal digit"));
|
||||
// Not a decimal digit
|
||||
}
|
||||
eci = eci * 10 + (next_digit - 2);
|
||||
@@ -194,7 +190,7 @@ fn get_encoded_data(corrected_bits: &[bool]) -> Result<String, Exceptions> {
|
||||
}
|
||||
let charset_eci = CharacterSetECI::getCharacterSetECIByValue(eci);
|
||||
if charset_eci.is_err() {
|
||||
return Err(Exceptions::format("Charset must exist".to_owned()));
|
||||
return Err(Exceptions::format("Charset must exist"));
|
||||
}
|
||||
encdr = CharacterSetECI::getCharset(&charset_eci?);
|
||||
}
|
||||
@@ -238,7 +234,7 @@ fn get_encoded_data(corrected_bits: &[bool]) -> Result<String, Exceptions> {
|
||||
if let Ok(str) = encdr.decode(&decoded_bytes, encoding::DecoderTrap::Strict) {
|
||||
result.push_str(&str);
|
||||
} else {
|
||||
return Err(Exceptions::illegalState("bad encoding".to_owned()));
|
||||
return Err(Exceptions::illegalState("bad encoding"));
|
||||
}
|
||||
// result.push_str(decodedBytes.toString(encoding.name()));
|
||||
//} catch (UnsupportedEncodingException uee) {
|
||||
@@ -290,7 +286,7 @@ fn get_character(table: Table, code: u32) -> Result<&'static str, Exceptions> {
|
||||
Table::Mixed => Ok(MIXED_TABLE[code as usize]),
|
||||
Table::Digit => Ok(DIGIT_TABLE[code as usize]),
|
||||
Table::Punct => Ok(PUNCT_TABLE[code as usize]),
|
||||
_ => Err(Exceptions::illegalState("Bad table".to_owned())),
|
||||
_ => Err(Exceptions::illegalState("Bad table")),
|
||||
}
|
||||
// switch (table) {
|
||||
// case UPPER:
|
||||
|
||||
@@ -127,7 +127,7 @@ impl<'a> Detector<'_> {
|
||||
|| !self.is_valid(&bulls_eye_corners[2])
|
||||
|| !self.is_valid(&bulls_eye_corners[3])
|
||||
{
|
||||
return Err(Exceptions::notFound("no valid points".to_owned()));
|
||||
return Err(Exceptions::notFound("no valid points"));
|
||||
}
|
||||
let length = 2 * self.nb_center_layers;
|
||||
// Get the bits around the bull's eye
|
||||
@@ -208,7 +208,7 @@ impl<'a> Detector<'_> {
|
||||
return Ok(shift);
|
||||
}
|
||||
}
|
||||
Err(Exceptions::notFound("rotation failure".to_owned()))
|
||||
Err(Exceptions::notFound("rotation failure"))
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -188,13 +188,13 @@ pub fn encode_bytes_with_charset(
|
||||
stuffed_bits = stuffBits(&bits, word_size as usize)?;
|
||||
if stuffed_bits.getSize() as u32 + ecc_bits > usable_bits_in_layers {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Data to large for user specified layer".to_owned(),
|
||||
"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(
|
||||
"Data to large for user specified layer".to_owned(),
|
||||
"Data to large for user specified layer",
|
||||
));
|
||||
}
|
||||
} else {
|
||||
@@ -208,7 +208,7 @@ pub fn encode_bytes_with_charset(
|
||||
// for (int i = 0; ; i++) {
|
||||
if i > MAX_NB_BITS {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"Data too large for an Aztec code".to_owned(),
|
||||
"Data too large for an Aztec code",
|
||||
));
|
||||
}
|
||||
compact = i <= 3;
|
||||
|
||||
@@ -248,9 +248,7 @@ impl HighLevelEncoder {
|
||||
initial_state = initial_state.appendFLGn(CharacterSetECI::getValue(&eci))?;
|
||||
}
|
||||
} else {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"No ECI code for character set".to_owned(),
|
||||
));
|
||||
return Err(Exceptions::illegalArgument("No ECI code for character set"));
|
||||
}
|
||||
// if self.charset != null {
|
||||
// CharacterSetECI eci = CharacterSetECI.getCharacterSetECI(charset);
|
||||
|
||||
@@ -81,7 +81,7 @@ impl State {
|
||||
} else */
|
||||
if eci > 999999 {
|
||||
return Err(Exceptions::illegalArgument(
|
||||
"ECI code must be between 0 and 999999".to_owned(),
|
||||
"ECI code must be between 0 and 999999",
|
||||
));
|
||||
// throw new IllegalArgumentException("ECI code must be between 0 and 999999");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user