mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
build result
This commit is contained in:
@@ -16,7 +16,10 @@
|
||||
|
||||
use std::{collections::HashMap, fmt};
|
||||
|
||||
use crate::{BarcodeFormat, Point, RXingResultMetadataType, RXingResultMetadataValue};
|
||||
use crate::{
|
||||
common::cpp_essentials::DecoderResult, BarcodeFormat, MetadataDictionary, Point,
|
||||
RXingResultMetadataType, RXingResultMetadataValue,
|
||||
};
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -95,6 +98,44 @@ impl RXingResult {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_decoder_result<T>(
|
||||
res: DecoderResult<T>,
|
||||
resultPoints: &[Point],
|
||||
format: BarcodeFormat,
|
||||
) -> Self
|
||||
where
|
||||
T: Copy + Clone + Default + Eq + PartialEq,
|
||||
{
|
||||
let mut new_res = Self::new(
|
||||
&res.text(),
|
||||
res.content().bytes().to_vec(),
|
||||
resultPoints.to_vec(),
|
||||
format,
|
||||
);
|
||||
|
||||
let mut meta_data = MetadataDictionary::new();
|
||||
meta_data.insert(
|
||||
RXingResultMetadataType::ERROR_CORRECTION_LEVEL,
|
||||
RXingResultMetadataValue::ErrorCorrectionLevel(res.ecLevel().to_owned()),
|
||||
);
|
||||
meta_data.insert(
|
||||
RXingResultMetadataType::STRUCTURED_APPEND_PARITY,
|
||||
RXingResultMetadataValue::StructuredAppendParity(res.structuredAppend().count),
|
||||
);
|
||||
meta_data.insert(
|
||||
RXingResultMetadataType::STRUCTURED_APPEND_SEQUENCE,
|
||||
RXingResultMetadataValue::StructuredAppendSequence(res.structuredAppend().index),
|
||||
);
|
||||
meta_data.insert(
|
||||
RXingResultMetadataType::SYMBOLOGY_IDENTIFIER,
|
||||
RXingResultMetadataValue::SymbologyIdentifier(res.symbologyIdentifier()),
|
||||
);
|
||||
|
||||
new_res.putAllMetadata(meta_data);
|
||||
|
||||
new_res
|
||||
}
|
||||
|
||||
/**
|
||||
* @return raw text encoded by the barcode
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user