font_types

Trait Scalar

Source
pub trait Scalar: Sized {
    type Raw: BeByteArray;

    // Required methods
    fn from_raw(raw: Self::Raw) -> Self;
    fn to_raw(self) -> Self::Raw;

    // Provided method
    fn read(slice: &[u8]) -> Option<Self> { ... }
}
Expand description

A trait for font scalars.

This is an internal trait for encoding and decoding big-endian bytes.

You do not need to implement this trait directly; it is an implementation detail of the BigEndian wrapper.

Required Associated Types§

Source

type Raw: BeByteArray

The raw byte representation of this type.

Required Methods§

Source

fn from_raw(raw: Self::Raw) -> Self

Create an instance of this type from raw big-endian bytes

Source

fn to_raw(self) -> Self::Raw

Encode this type as raw big-endian bytes

Provided Methods§

Source

fn read(slice: &[u8]) -> Option<Self>

Attempt to read a scalar from a slice.

This will always succeed if slice.len() == Self::RAW_BYTE_LEN, and will always return None otherwise.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Scalar for i8

Source§

type Raw = [u8; 1]

Source§

fn to_raw(self) -> [u8; 1]

Source§

fn from_raw(raw: [u8; 1]) -> i8

Source§

impl Scalar for i16

Source§

type Raw = [u8; 2]

Source§

fn to_raw(self) -> [u8; 2]

Source§

fn from_raw(raw: [u8; 2]) -> i16

Source§

impl Scalar for i32

Source§

type Raw = [u8; 4]

Source§

fn to_raw(self) -> [u8; 4]

Source§

fn from_raw(raw: [u8; 4]) -> i32

Source§

impl Scalar for i64

Source§

type Raw = [u8; 8]

Source§

fn to_raw(self) -> [u8; 8]

Source§

fn from_raw(raw: [u8; 8]) -> i64

Source§

impl Scalar for u8

Source§

type Raw = [u8; 1]

Source§

fn to_raw(self) -> [u8; 1]

Source§

fn from_raw(raw: [u8; 1]) -> u8

Source§

impl Scalar for u16

Source§

type Raw = [u8; 2]

Source§

fn to_raw(self) -> [u8; 2]

Source§

fn from_raw(raw: [u8; 2]) -> u16

Source§

impl Scalar for u32

Source§

type Raw = [u8; 4]

Source§

fn to_raw(self) -> [u8; 4]

Source§

fn from_raw(raw: [u8; 4]) -> u32

Implementors§

Source§

impl Scalar for F2Dot14

Source§

type Raw = [u8; 2]

Source§

impl Scalar for F4Dot12

Source§

type Raw = [u8; 2]

Source§

impl Scalar for F6Dot10

Source§

type Raw = [u8; 2]

Source§

impl Scalar for FWord

Source§

type Raw = [u8; 2]

Source§

impl Scalar for Fixed

Source§

type Raw = [u8; 4]

Source§

impl Scalar for GlyphId16

Source§

type Raw = [u8; 2]

Source§

impl Scalar for Int24

Source§

type Raw = [u8; 3]

Source§

impl Scalar for LongDateTime

Source§

type Raw = [u8; 8]

Source§

impl Scalar for MajorMinor

Source§

type Raw = [u8; 4]

Source§

impl Scalar for NameId

Source§

type Raw = [u8; 2]

Source§

impl Scalar for Offset16

Source§

type Raw = <u16 as Scalar>::Raw

Source§

impl Scalar for Offset24

Source§

impl Scalar for Offset32

Source§

type Raw = <u32 as Scalar>::Raw

Source§

impl Scalar for Tag

Source§

type Raw = [u8; 4]

Source§

impl Scalar for UfWord

Source§

type Raw = [u8; 2]

Source§

impl Scalar for Uint24

Source§

type Raw = [u8; 3]

Source§

impl Scalar for Version16Dot16

Source§

type Raw = [u8; 4]

Source§

impl<T: Scalar> Scalar for Nullable<T>

Source§

type Raw = <T as Scalar>::Raw

impl Scalar for Extend

impl Scalar for GvarFlags

impl Scalar for MacStyle

impl Scalar for VarcFlags