pub struct Version16Dot16(/* private fields */);Expand description
An OpenType Version16Dot16 version.
The upper 16 bits comprise a major version number, and the highest-order nibble (4 bits) of the
lower 16 bits comprises a minor version number (0..=9 range). Simply put, the major version is
in 0xFFFF0000, and the minor version is in 0x0000F000.
Implementations§
Source§impl Version16Dot16
impl Version16Dot16
Sourcepub const fn new(major: u16, minor: u8) -> Option<Self>
pub const fn new(major: u16, minor: u8) -> Option<Self>
Creates a Version16Dot16 from major and minor version numbers.
§Examples
use ttf_view::types::Version16Dot16;
assert_eq!(Version16Dot16::new(0, 5).unwrap().tuple(), (0, 5));
assert_eq!(Version16Dot16::new(15, 9).unwrap().tuple(), (15, 9));
assert_eq!(Version16Dot16::new(0xFFFF, 9).unwrap().tuple(), (0xFFFF, 9));
assert_eq!(Version16Dot16::new(15, 10), None);
assert_eq!(Version16Dot16::new(1, 199), None);Sourcepub const unsafe fn new_unchecked(major: u16, minor: u8) -> Self
pub const unsafe fn new_unchecked(major: u16, minor: u8) -> Self
Creates a Version16Dot16 from major and minor version numbers without checks.
§Examples
use ttf_view::types::Version16Dot16;
assert_eq!(unsafe { Version16Dot16::new_unchecked(0, 5).tuple() }, (0, 5));
assert_eq!(unsafe { Version16Dot16::new_unchecked(0xFFFF, 9).tuple() }, (0xFFFF, 9));Sourcepub const fn from_be_bytes(bytes: [u8; 4]) -> Option<Self>
pub const fn from_be_bytes(bytes: [u8; 4]) -> Option<Self>
Creates a Version16Dot16 from big-endian bytes.
§Examples
use ttf_view::types::Version16Dot16;
assert_eq!(Version16Dot16::from_be_bytes([0x00, 0x00, 0x50, 0x00]).unwrap().tuple(), (0, 5));
assert_eq!(Version16Dot16::from_be_bytes([0x00, 0x01, 0x90, 0x00]).unwrap().tuple(), (1, 9));
assert_eq!(Version16Dot16::from_be_bytes([0x12, 0x34, 0x90, 0x00]).unwrap().tuple(), (0x1234, 9));
assert_eq!(Version16Dot16::from_be_bytes([0x00, 0x01, 0xA0, 0x00]), None);
assert_eq!(Version16Dot16::from_be_bytes([0x00, 0x01, 0x90, 0x64]), None);Sourcepub const unsafe fn from_be_bytes_unchecked(bytes: [u8; 4]) -> Self
pub const unsafe fn from_be_bytes_unchecked(bytes: [u8; 4]) -> Self
Creates a Version16Dot16 from big-endian bytes without checks.
§Examples
use ttf_view::types::Version16Dot16;
assert_eq!(unsafe { Version16Dot16::from_be_bytes_unchecked([0x00, 0x00, 0x50, 0x00]).tuple() }, (0, 5));
assert_eq!(unsafe { Version16Dot16::from_be_bytes_unchecked([0x00, 0x01, 0x90, 0x00]).tuple() }, (1, 9));
assert_eq!(unsafe { Version16Dot16::from_be_bytes_unchecked([0x12, 0x34, 0x90, 0x00]).tuple() }, (0x1234, 9));Sourcepub const fn to_be_bytes(self) -> [u8; 4]
pub const fn to_be_bytes(self) -> [u8; 4]
Gets this Version16Dot16’s big-endian bytes.
§Examples
use ttf_view::types::Version16Dot16;
assert_eq!(Version16Dot16::new(1, 5).unwrap().to_be_bytes(), [0x00, 0x01, 0x50, 0x00]);
assert_eq!(Version16Dot16::new(0x1234, 5).unwrap().to_be_bytes(), [0x12, 0x34, 0x50, 0x00]);
assert_eq!(Version16Dot16::new(0x1234, 9).unwrap().to_be_bytes(), [0x12, 0x34, 0x90, 0x00]);Sourcepub const fn major(&self) -> u16
pub const fn major(&self) -> u16
Gets this Version16Dot16’s major version number.
§Examples
use ttf_view::types::Version16Dot16;
assert_eq!(Version16Dot16::new(0, 9).unwrap().major(), 0);
assert_eq!(Version16Dot16::new(13, 2).unwrap().major(), 13);
assert_eq!(Version16Dot16::new(0xFFFF, 5).unwrap().major(), 0xFFFF);Sourcepub const fn minor(&self) -> u8
pub const fn minor(&self) -> u8
Gets this Version16Dot16’s minor version number.
§Examples
use ttf_view::types::Version16Dot16;
assert_eq!(Version16Dot16::new(0, 9).unwrap().minor(), 9);
assert_eq!(Version16Dot16::new(13, 2).unwrap().minor(), 2);
assert_eq!(Version16Dot16::new(0xFFFF, 5).unwrap().minor(), 5);Sourcepub const fn tuple(&self) -> (u16, u8)
pub const fn tuple(&self) -> (u16, u8)
Gets this Version16Dot16’s major and minor version numbers as a tuple.
§Examples
use ttf_view::types::Version16Dot16;
assert_eq!(Version16Dot16::new(0, 9).unwrap().tuple(), (0, 9));
assert_eq!(Version16Dot16::new(13, 2).unwrap().tuple(), (13, 2));
assert_eq!(Version16Dot16::new(0xFFFF, 5).unwrap().tuple(), (0xFFFF, 5));Trait Implementations§
Source§impl Clone for Version16Dot16
impl Clone for Version16Dot16
impl Copy for Version16Dot16
Source§impl Debug for Version16Dot16
impl Debug for Version16Dot16
Source§impl Default for Version16Dot16
impl Default for Version16Dot16
Source§impl Display for Version16Dot16
impl Display for Version16Dot16
impl Eq for Version16Dot16
Source§impl From<BigEndian<Version16Dot16>> for Version16Dot16
impl From<BigEndian<Version16Dot16>> for Version16Dot16
Source§fn from(value: BigEndian<Version16Dot16>) -> Self
fn from(value: BigEndian<Version16Dot16>) -> Self
Converts to this type from the input type.
Source§impl FromStr for Version16Dot16
impl FromStr for Version16Dot16
Source§impl Hash for Version16Dot16
impl Hash for Version16Dot16
Source§impl LowerHex for Version16Dot16
impl LowerHex for Version16Dot16
Source§impl Ord for Version16Dot16
impl Ord for Version16Dot16
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for Version16Dot16
impl PartialEq for Version16Dot16
Source§impl PartialOrd for Version16Dot16
impl PartialOrd for Version16Dot16
Source§impl Primitive for Version16Dot16
impl Primitive for Version16Dot16
impl StructuralPartialEq for Version16Dot16
Auto Trait Implementations§
impl Freeze for Version16Dot16
impl RefUnwindSafe for Version16Dot16
impl Send for Version16Dot16
impl Sync for Version16Dot16
impl Unpin for Version16Dot16
impl UnsafeUnpin for Version16Dot16
impl UnwindSafe for Version16Dot16
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
Mutably borrows from an owned value. Read more