|
|
|
@ -1220,30 +1220,40 @@ impl BitBuffer {
|
|
|
|
|
|
|
|
|
|
/*---- Miscellaneous values ----*/
|
|
|
|
|
|
|
|
|
|
/// A number between 1 and 40 (inclusive).
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
|
pub struct Version(u8);
|
|
|
|
|
|
|
|
|
|
impl Version {
|
|
|
|
|
/// Creates a version object from the given number.
|
|
|
|
|
///
|
|
|
|
|
/// Panics if the number is outside the range [1, 40].
|
|
|
|
|
pub fn new(ver: u8) -> Self {
|
|
|
|
|
assert!(QrCode_MIN_VERSION.value() <= ver && ver <= QrCode_MAX_VERSION.value(), "Version number out of range");
|
|
|
|
|
Version(ver)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns the value, which is in the range [1, 40].
|
|
|
|
|
pub fn value(&self) -> u8 {
|
|
|
|
|
self.0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// A number between 0 and 7 (inclusive).
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
|
pub struct Mask(u8);
|
|
|
|
|
|
|
|
|
|
impl Mask {
|
|
|
|
|
/// Creates a mask object from the given number.
|
|
|
|
|
///
|
|
|
|
|
/// Panics if the number is outside the range [0, 7].
|
|
|
|
|
pub fn new(mask: u8) -> Self {
|
|
|
|
|
assert!(mask <= 7, "Mask value out of range");
|
|
|
|
|
Mask(mask)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Returns the value, which is in the range [0, 7].
|
|
|
|
|
pub fn value(&self) -> u8 {
|
|
|
|
|
self.0
|
|
|
|
|
}
|
|
|
|
|