rename helper methods

This commit is contained in:
Vukašin Stepanović
2023-02-15 12:52:59 +00:00
parent bfcdb397ad
commit 935519ced5
133 changed files with 858 additions and 1044 deletions

View File

@@ -86,7 +86,7 @@ pub fn decode(bytes: &[u8], mode: u8) -> Result<DecoderRXingResult, Exceptions>
let pc = getPostCode2(bytes);
let ps2Length = getPostCode2Length(bytes) as usize;
if ps2Length > 10 {
return Err(Exceptions::formatEmpty());
return Err(Exceptions::format);
}
// NumberFormat df = new DecimalFormat("0000000000".substring(0, ps2Length));
// postcode = df.format(pc);

View File

@@ -70,7 +70,7 @@ pub fn decode_with_hints(
correctErrors(&mut codewords, 20, 68, 56, ODD)?;
datawords = vec![0u8; 78];
}
_ => return Err(Exceptions::notFoundEmpty()),
_ => return Err(Exceptions::notFound),
}
datawords[0..10].clone_from_slice(&codewords[0..10]);

View File

@@ -318,7 +318,7 @@ impl Circle<'_> {
pub fn detect(image: &BitMatrix, try_harder: bool) -> Result<MaxicodeDetectionResult, Exceptions> {
// find concentric circles
let Some( mut circles) = find_concentric_circles(image) else {
return Err(Exceptions::notFoundEmpty());
return Err(Exceptions::notFound);
};
// we should have an idea where the center is at this point,
@@ -341,7 +341,7 @@ pub fn detect(image: &BitMatrix, try_harder: bool) -> Result<MaxicodeDetectionRe
if try_harder {
continue;
}else {
return Err(Exceptions::notFoundEmpty())
return Err(Exceptions::notFound)
}
};
let grid_sampler = DefaultGridSampler::default();
@@ -378,7 +378,7 @@ pub fn detect(image: &BitMatrix, try_harder: bool) -> Result<MaxicodeDetectionRe
if try_harder {
continue;
}else {
return Err(Exceptions::notFoundEmpty())
return Err(Exceptions::notFound)
}
};
return Ok(MaxicodeDetectionResult {
@@ -392,7 +392,7 @@ pub fn detect(image: &BitMatrix, try_harder: bool) -> Result<MaxicodeDetectionRe
});
}
Err(Exceptions::notFoundEmpty())
Err(Exceptions::notFound)
}
/// Locate concentric circles.
@@ -734,7 +734,7 @@ fn box_symbol(
#[cfg(feature = "experimental_features")]
if is_ellipse {
// we don't deal with ellipses yet
return Err(Exceptions::notFoundEmpty());
return Err(Exceptions::notFound);
}
let mut final_rotation = 0.0;
@@ -1052,9 +1052,7 @@ fn compare_circle(a: &Circle, b: &Circle) -> std::cmp::Ordering {
/// Read appropriate bits from a bitmatrix for the maxicode decoder
pub fn read_bits(image: &BitMatrix) -> Result<BitMatrix, Exceptions> {
let enclosingRectangle = image
.getEnclosingRectangle()
.ok_or(Exceptions::notFoundEmpty())?;
let enclosingRectangle = image.getEnclosingRectangle().ok_or(Exceptions::notFound)?;
let left = enclosingRectangle[0];
let top = enclosingRectangle[1];

View File

@@ -126,10 +126,10 @@ impl MaxiCodeReader {
fn extractPureBits(image: &BitMatrix) -> Result<BitMatrix, Exceptions> {
let enclosingRectangleOption = image.getEnclosingRectangle();
if enclosingRectangleOption.is_none() {
return Err(Exceptions::notFoundEmpty());
return Err(Exceptions::notFound);
}
let enclosingRectangle = enclosingRectangleOption.ok_or(Exceptions::notFoundEmpty())?;
let enclosingRectangle = enclosingRectangleOption.ok_or(Exceptions::notFound)?;
let left = enclosingRectangle[0];
let top = enclosingRectangle[1];