pub enum Mode {
Numeric,
Alphanumeric,
Byte,
Kanji,
}Expand description
The mode indicator, which specifies the character set of the encoded data.
Variants§
Numeric
The data contains only characters 0 to 9.
Alphanumeric
The data contains only uppercase letters (A–Z), numbers (0–9) and a few
punctuations marks (space, $, %, *, +, -, ., /, :).
Byte
The data contains arbitrary binary data.
Kanji
The data contains Shift-JIS-encoded double-byte text.
Implementations§
Source§impl Mode
impl Mode
Sourcepub fn length_bits_count(self, version: Version) -> usize
pub fn length_bits_count(self, version: Version) -> usize
Computes the number of bits needed to encode the data length.
use qrcode_core::types::{Version, Mode};
assert_eq!(Mode::Numeric.length_bits_count(Version::Normal(1)), 10);This method will return Err(QrError::UnsupportedCharacterSet) if the
mode is not supported in the given version.
Sourcepub fn data_bits_count(self, raw_data_len: usize) -> usize
pub fn data_bits_count(self, raw_data_len: usize) -> usize
Computes the number of bits needed to some data of a given raw length.
use qrcode_core::types::Mode;
assert_eq!(Mode::Numeric.data_bits_count(7), 24);Note that in Kanji mode, the raw_data_len is the number of Kanjis,
i.e. half the total size of bytes.
Trait Implementations§
impl Copy for Mode
Source§impl<'de> Deserialize<'de> for Mode
impl<'de> Deserialize<'de> for Mode
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Mode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Mode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for Mode
Source§impl FromStr for Mode
impl FromStr for Mode
Source§fn from_str(s: &str) -> Result<Mode, <Mode as FromStr>::Err>
fn from_str(s: &str) -> Result<Mode, <Mode as FromStr>::Err>
Parses a mode by name, case-insensitively: numeric, alphanumeric,
byte or kanji.
§Examples
use core::str::FromStr;
use qrcode_core::types::Mode;
assert_eq!(Mode::from_str("Byte"), Ok(Mode::Byte));
assert!(Mode::from_str("utf8").is_err());Source§type Err = EnumParseError
type Err = EnumParseError
Source§impl PartialOrd for Mode
impl PartialOrd for Mode
Source§fn partial_cmp(&self, other: &Mode) -> Option<Ordering>
fn partial_cmp(&self, other: &Mode) -> Option<Ordering>
Defines a partial ordering between modes. If a <= b, then b contains
a superset of all characters supported by a.
Source§impl Serialize for Mode
impl Serialize for Mode
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 Mode
Auto Trait Implementations§
impl Freeze for Mode
impl RefUnwindSafe for Mode
impl Send for Mode
impl Sync for Mode
impl Unpin for Mode
impl UnsafeUnpin for Mode
impl UnwindSafe for Mode
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.