From 7ddeb4906497747987a1760c45b0185610bcc55f Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Wed, 11 Jan 2023 16:06:35 -0600 Subject: [PATCH] return a slice for RXingResultPoints --- src/aztec/AztecDetectorResult.rs | 2 +- src/common/mod.rs | 2 +- src/datamatrix/data_matrix_reader.rs | 2 +- src/datamatrix/detector/datamatrix_result.rs | 2 +- src/multi/qrcode/qr_code_multi_reader.rs | 4 ++-- src/qrcode/detector/qrcode_detector_result.rs | 2 +- src/qrcode/qr_code_reader.rs | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/aztec/AztecDetectorResult.rs b/src/aztec/AztecDetectorResult.rs index 695ff15..7275aee 100644 --- a/src/aztec/AztecDetectorResult.rs +++ b/src/aztec/AztecDetectorResult.rs @@ -44,7 +44,7 @@ impl DetectorRXingResult for AztecDetectorRXingResult { &self.bits } - fn getPoints(&self) -> &Vec { + fn getPoints(&self) -> &[RXingResultPoint] { &self.points } } diff --git a/src/common/mod.rs b/src/common/mod.rs index 634e1ab..b77b76e 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -54,7 +54,7 @@ pub use bit_array::*; pub trait DetectorRXingResult { fn getBits(&self) -> &BitMatrix; - fn getPoints(&self) -> &Vec; + fn getPoints(&self) -> &[RXingResultPoint]; } // pub struct DetectorRXingResult { diff --git a/src/datamatrix/data_matrix_reader.rs b/src/datamatrix/data_matrix_reader.rs index 84dd933..945f34a 100644 --- a/src/datamatrix/data_matrix_reader.rs +++ b/src/datamatrix/data_matrix_reader.rs @@ -78,7 +78,7 @@ impl Reader for DataMatrixReader { } else { let detectorRXingResult = Detector::new(image.getBlackMatrix())?.detect()?; decoderRXingResult = DECODER.decode(detectorRXingResult.getBits())?; - points = detectorRXingResult.getPoints().clone(); + points = detectorRXingResult.getPoints().to_vec(); } let mut result = RXingResult::new( decoderRXingResult.getText(), diff --git a/src/datamatrix/detector/datamatrix_result.rs b/src/datamatrix/detector/datamatrix_result.rs index 36f095e..40811e5 100644 --- a/src/datamatrix/detector/datamatrix_result.rs +++ b/src/datamatrix/detector/datamatrix_result.rs @@ -16,7 +16,7 @@ impl DetectorRXingResult for DatamatrixDetectorResult { &self.0 } - fn getPoints(&self) -> &Vec { + fn getPoints(&self) -> &[RXingResultPoint] { &self.1 } } diff --git a/src/multi/qrcode/qr_code_multi_reader.rs b/src/multi/qrcode/qr_code_multi_reader.rs index 1be009c..65c9a06 100644 --- a/src/multi/qrcode/qr_code_multi_reader.rs +++ b/src/multi/qrcode/qr_code_multi_reader.rs @@ -57,7 +57,7 @@ impl MultipleBarcodeReader for QRCodeMultiReader { detectorRXingResult.getBits(), 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 let Some(other) = decoderRXingResult.getOther() { if other.is::() { @@ -73,7 +73,7 @@ impl MultipleBarcodeReader for QRCodeMultiReader { let mut result = RXingResult::new( decoderRXingResult.getText(), decoderRXingResult.getRawBytes().clone(), - points, + points.to_vec(), BarcodeFormat::QR_CODE, ); let byteSegments = decoderRXingResult.getByteSegments(); diff --git a/src/qrcode/detector/qrcode_detector_result.rs b/src/qrcode/detector/qrcode_detector_result.rs index 1252a06..fa9070f 100644 --- a/src/qrcode/detector/qrcode_detector_result.rs +++ b/src/qrcode/detector/qrcode_detector_result.rs @@ -22,7 +22,7 @@ impl DetectorRXingResult for QRCodeDetectorResult { &self.bit_source } - fn getPoints(&self) -> &Vec { + fn getPoints(&self) -> &[crate::RXingResultPoint] { &self.result_points } } diff --git a/src/qrcode/qr_code_reader.rs b/src/qrcode/qr_code_reader.rs index 61697b2..2131954 100644 --- a/src/qrcode/qr_code_reader.rs +++ b/src/qrcode/qr_code_reader.rs @@ -71,7 +71,7 @@ impl Reader for QRCodeReader { Detector::new(image.getBlackMatrix()).detect_with_hints(hints)?; decoderRXingResult = 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.