return a slice for RXingResultPoints

This commit is contained in:
Henry Schimke
2023-01-11 16:06:35 -06:00
parent fde23934f6
commit 7ddeb49064
7 changed files with 8 additions and 8 deletions

View File

@@ -44,7 +44,7 @@ impl DetectorRXingResult for AztecDetectorRXingResult {
&self.bits &self.bits
} }
fn getPoints(&self) -> &Vec<RXingResultPoint> { fn getPoints(&self) -> &[RXingResultPoint] {
&self.points &self.points
} }
} }

View File

@@ -54,7 +54,7 @@ pub use bit_array::*;
pub trait DetectorRXingResult { pub trait DetectorRXingResult {
fn getBits(&self) -> &BitMatrix; fn getBits(&self) -> &BitMatrix;
fn getPoints(&self) -> &Vec<RXingResultPoint>; fn getPoints(&self) -> &[RXingResultPoint];
} }
// pub struct DetectorRXingResult { // pub struct DetectorRXingResult {

View File

@@ -78,7 +78,7 @@ impl Reader for DataMatrixReader {
} else { } else {
let detectorRXingResult = Detector::new(image.getBlackMatrix())?.detect()?; let detectorRXingResult = Detector::new(image.getBlackMatrix())?.detect()?;
decoderRXingResult = DECODER.decode(detectorRXingResult.getBits())?; decoderRXingResult = DECODER.decode(detectorRXingResult.getBits())?;
points = detectorRXingResult.getPoints().clone(); points = detectorRXingResult.getPoints().to_vec();
} }
let mut result = RXingResult::new( let mut result = RXingResult::new(
decoderRXingResult.getText(), decoderRXingResult.getText(),

View File

@@ -16,7 +16,7 @@ impl DetectorRXingResult for DatamatrixDetectorResult {
&self.0 &self.0
} }
fn getPoints(&self) -> &Vec<RXingResultPoint> { fn getPoints(&self) -> &[RXingResultPoint] {
&self.1 &self.1
} }
} }

View File

@@ -57,7 +57,7 @@ impl MultipleBarcodeReader for QRCodeMultiReader {
detectorRXingResult.getBits(), detectorRXingResult.getBits(),
hints, hints,
)?; )?;
let mut points = detectorRXingResult.getPoints().clone(); let mut points = detectorRXingResult.getPoints().to_vec();
// If the code was mirrored: swap the bottom-left and the top-right points. // If the code was mirrored: swap the bottom-left and the top-right points.
if let Some(other) = decoderRXingResult.getOther() { if let Some(other) = decoderRXingResult.getOther() {
if other.is::<QRCodeDecoderMetaData>() { if other.is::<QRCodeDecoderMetaData>() {
@@ -73,7 +73,7 @@ impl MultipleBarcodeReader for QRCodeMultiReader {
let mut result = RXingResult::new( let mut result = RXingResult::new(
decoderRXingResult.getText(), decoderRXingResult.getText(),
decoderRXingResult.getRawBytes().clone(), decoderRXingResult.getRawBytes().clone(),
points, points.to_vec(),
BarcodeFormat::QR_CODE, BarcodeFormat::QR_CODE,
); );
let byteSegments = decoderRXingResult.getByteSegments(); let byteSegments = decoderRXingResult.getByteSegments();

View File

@@ -22,7 +22,7 @@ impl DetectorRXingResult for QRCodeDetectorResult {
&self.bit_source &self.bit_source
} }
fn getPoints(&self) -> &Vec<crate::RXingResultPoint> { fn getPoints(&self) -> &[crate::RXingResultPoint] {
&self.result_points &self.result_points
} }
} }

View File

@@ -71,7 +71,7 @@ impl Reader for QRCodeReader {
Detector::new(image.getBlackMatrix()).detect_with_hints(hints)?; Detector::new(image.getBlackMatrix()).detect_with_hints(hints)?;
decoderRXingResult = decoderRXingResult =
qrcode_decoder::decode_bitmatrix_with_hints(detectorRXingResult.getBits(), hints)?; qrcode_decoder::decode_bitmatrix_with_hints(detectorRXingResult.getBits(), hints)?;
points = detectorRXingResult.getPoints().clone(); points = detectorRXingResult.getPoints().to_vec();
} }
// If the code was mirrored: swap the bottom-left and the top-right points. // If the code was mirrored: swap the bottom-left and the top-right points.