pub enum Version {
Normal(i16),
Micro(i16),
}Expand description
In QR code terminology, Version means the size of the generated image.
Larger version means the size of code is larger, and therefore can carry
more information.
The smallest version is Version::Normal(1) of size 21×21, and the largest
is Version::Normal(40) of size 177×177.
Variants§
Normal(i16)
A normal QR code version. The parameter should be between 1 and 40.
Micro(i16)
A Micro QR code version. The parameter should be between 1 and 4.
Implementations§
Source§impl Version
impl Version
Sourcepub const fn width(self) -> i16
pub const fn width(self) -> i16
Get the number of “modules” on each size of the QR code, i.e. the width and height of the code.
Sourcepub fn fetch<T>(self, ec_level: EcLevel, table: &[[T; 4]]) -> Result<T, QrError>
pub fn fetch<T>(self, ec_level: EcLevel, table: &[[T; 4]]) -> Result<T, QrError>
Obtains an object from a hard-coded table.
The table must be a 44×4 array. The outer array represents the content for each version. The first 40 entry corresponds to QR code versions 1 to 40, and the last 4 corresponds to Micro QR code version 1 to 4. The inner array represents the content in each error correction level, in the order [L, M, Q, H].
§Errors
If the entry compares equal to the default value of T, this method
returns Err(QrError::InvalidVersion).
Sourcepub fn mode_bits_count(self) -> usize
pub fn mode_bits_count(self) -> usize
The number of bits needed to encode the mode indicator.
Trait Implementations§
impl Copy for Version
Source§impl<'de> Deserialize<'de> for Version
impl<'de> Deserialize<'de> for Version
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Version, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Version, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for Version
Source§impl FromStr for Version
impl FromStr for Version
Source§fn from_str(s: &str) -> Result<Version, <Version as FromStr>::Err>
fn from_str(s: &str) -> Result<Version, <Version as FromStr>::Err>
Parses a normal QR version 1..=40 (e.g. "5" → Normal(5)) or a
Micro QR version M1..M4 (e.g. "m2" → Micro(2)), case-insensitively.
§Examples
use core::str::FromStr;
use qrcode_core::types::Version;
assert_eq!(Version::from_str("5"), Ok(Version::Normal(5)));
assert_eq!(Version::from_str("M4"), Ok(Version::Micro(4)));
assert!(Version::from_str("99").is_err());Source§type Err = EnumParseError
type Err = EnumParseError
Source§impl Serialize for Version
impl Serialize for Version
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Version
Auto Trait Implementations§
impl Freeze for Version
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnsafeUnpin for Version
impl UnwindSafe for Version
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.