mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-28 05:12:34 +00:00
removed todo!() from qrcode_version.rs
This commit is contained in:
@@ -2,9 +2,9 @@ use crate::qrcode::decoder::FormatInformation;
|
|||||||
|
|
||||||
impl FormatInformation {
|
impl FormatInformation {
|
||||||
/**
|
/**
|
||||||
* @param formatInfoBits1 format info indicator, with mask still applied
|
* @param formatInfoBits1 format info indicator, with mask still applied
|
||||||
* @param formatInfoBits2 second copy of same info; both are checked at the same time to establish best match
|
* @param formatInfoBits2 second copy of same info; both are checked at the same time to establish best match
|
||||||
*/
|
*/
|
||||||
pub fn DecodeQR(formatInfoBits1: u32, formatInfoBits2: u32) -> Self {
|
pub fn DecodeQR(formatInfoBits1: u32, formatInfoBits2: u32) -> Self {
|
||||||
todo!()
|
todo!()
|
||||||
// // maks out the 'Dark Module' for mirrored and non-mirrored case (see Figure 25 in ISO/IEC 18004:2015)
|
// // maks out the 'Dark Module' for mirrored and non-mirrored case (see Figure 25 in ISO/IEC 18004:2015)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::common::Result;
|
use crate::common::Result;
|
||||||
use crate::qrcode::decoder::{Version, VersionRef, VERSION_DECODE_INFO};
|
use crate::qrcode::decoder::{Version, VersionRef, MICRO_VERSIONS, VERSIONS, VERSION_DECODE_INFO};
|
||||||
use crate::Exceptions;
|
use crate::Exceptions;
|
||||||
|
|
||||||
// const Version* Version::AllMicroVersions()
|
// const Version* Version::AllMicroVersions()
|
||||||
@@ -17,13 +17,28 @@ use crate::Exceptions;
|
|||||||
|
|
||||||
impl Version {
|
impl Version {
|
||||||
pub fn FromDimension(dimension: u32) -> Result<VersionRef> {
|
pub fn FromDimension(dimension: u32) -> Result<VersionRef> {
|
||||||
todo!()
|
let isMicro = dimension < 21;
|
||||||
// bool isMicro = dimension < 21;
|
if (dimension % Self::DimensionStep(isMicro) != 1) {
|
||||||
// if (dimension % DimensionStep(isMicro) != 1) {
|
//throw std::invalid_argument("Unexpected dimension");
|
||||||
// //throw std::invalid_argument("Unexpected dimension");
|
return Err(Exceptions::ILLEGAL_ARGUMENT);
|
||||||
// return nullptr;
|
}
|
||||||
// }
|
return Self::FromNumber(
|
||||||
// return FromNumber((dimension - DimensionOffset(isMicro)) / DimensionStep(isMicro), isMicro);
|
(dimension - Self::DimensionOffset(isMicro)) / Self::DimensionStep(isMicro),
|
||||||
|
isMicro,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn FromNumber(versionNumber: u32, is_micro: bool) -> Result<VersionRef> {
|
||||||
|
if (versionNumber < 1 || versionNumber > (if is_micro { 4 } else { 40 })) {
|
||||||
|
//throw std::invalid_argument("Version should be in range [1-40].");
|
||||||
|
return Err(Exceptions::ILLEGAL_ARGUMENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(if is_micro {
|
||||||
|
&MICRO_VERSIONS[versionNumber as usize - 1]
|
||||||
|
} else {
|
||||||
|
&VERSIONS[versionNumber as usize - 1]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn DimensionOfVersion(version: u32, is_micro: bool) -> u32 {
|
pub fn DimensionOfVersion(version: u32, is_micro: bool) -> u32 {
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ use once_cell::sync::Lazy;
|
|||||||
|
|
||||||
pub type VersionRef = &'static Version;
|
pub type VersionRef = &'static Version;
|
||||||
|
|
||||||
static VERSIONS: Lazy<Vec<Version>> = Lazy::new(Version::buildVersions);
|
pub static VERSIONS: Lazy<Vec<Version>> = Lazy::new(Version::buildVersions);
|
||||||
static MICRO_VERSIONS: Lazy<Vec<Version>> = Lazy::new(Version::build_micro_versions);
|
pub static MICRO_VERSIONS: Lazy<Vec<Version>> = Lazy::new(Version::build_micro_versions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See ISO 18004:2006 Annex D.
|
* See ISO 18004:2006 Annex D.
|
||||||
|
|||||||
Reference in New Issue
Block a user