Skip to main content

Version16Dot16

Struct Version16Dot16 

Source
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

Source

pub const V0_5: Self

Version 0.5.

Source

pub const V1_0: Self

Version 1.0.

Source

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);
Source

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));
Source

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);
Source

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));
Source

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]);
Source

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);
Source

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);
Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Version16Dot16

Source§

impl Debug for Version16Dot16

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Version16Dot16

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Version16Dot16

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Version16Dot16

Source§

impl From<BigEndian<Version16Dot16>> for Version16Dot16

Source§

fn from(value: BigEndian<Version16Dot16>) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Version16Dot16

Source§

type Err = ParseVersion16Dot16Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Version16Dot16

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl LowerHex for Version16Dot16

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Ord for Version16Dot16

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Version16Dot16

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Version16Dot16

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Primitive for Version16Dot16

Source§

type BigEndian = [u8; 4]

Source§

fn from_big_endian(x: Self::BigEndian) -> Self

Source§

fn to_big_endian(x: Self) -> Self::BigEndian

Source§

impl StructuralPartialEq for Version16Dot16

Source§

impl UpperHex for Version16Dot16

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.