diff --git a/src/lib.rs b/src/lib.rs index 8bfe758..aef1a16 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ mod exceptions; pub mod maxicode; pub mod qrcode; -use std::collections::HashMap; +use std::{collections::HashMap, rc::Rc}; pub use exceptions::Exceptions; @@ -40,7 +40,7 @@ pub use encode_hints::*; * * @see DecodeHintType#NEED_RESULT_POINT_CALLBACK */ -pub type RXingResultPointCallback = fn(&dyn ResultPoint); +pub type RXingResultPointCallback = Rc; mod decode_hints; pub use decode_hints::*; diff --git a/src/multi/qrcode/detector/multi_detector.rs b/src/multi/qrcode/detector/multi_detector.rs index b126e6f..d4b48f3 100644 --- a/src/multi/qrcode/detector/multi_detector.rs +++ b/src/multi/qrcode/detector/multi_detector.rs @@ -45,7 +45,7 @@ impl<'a> MultiDetector<'_> { let resultPointCallback = if let Some(DecodeHintValue::NeedResultPointCallback(cb)) = hints.get(&DecodeHintType::NEED_RESULT_POINT_CALLBACK) { - Some(*cb) + Some(cb.clone()) } else { None }; diff --git a/src/qrcode/detector/qrcode_detector.rs b/src/qrcode/detector/qrcode_detector.rs index 1f1c36e..b4d11d5 100644 --- a/src/qrcode/detector/qrcode_detector.rs +++ b/src/qrcode/detector/qrcode_detector.rs @@ -84,7 +84,7 @@ impl<'a> Detector<'_> { hints.get(&DecodeHintType::NEED_RESULT_POINT_CALLBACK) { // if let DecodeHintValue::NeedResultPointCallback(cb) = nrpc { - Some(*cb) + Some(cb.clone()) // } else { // None // } @@ -97,7 +97,7 @@ impl<'a> Detector<'_> { // (RXingResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); let mut finder = - FinderPatternFinder::with_callback(self.image.clone(), self.resultPointCallback); + FinderPatternFinder::with_callback(self.image.clone(), self.resultPointCallback.clone()); let info = finder.find(hints)?; self.processFinderPatternInfo(info) @@ -479,7 +479,7 @@ impl<'a> Detector<'_> { alignmentAreaRightX - alignmentAreaLeftX, alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize, - self.resultPointCallback, + self.resultPointCallback.clone(), ); alignmentFinder.find() }