Trait font_types::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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Scalar for i8

§

type Raw = [u8; 1]

source§

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

source§

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

source§

impl Scalar for i16

§

type Raw = [u8; 2]

source§

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

source§

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

source§

impl Scalar for i32

§

type Raw = [u8; 4]

source§

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

source§

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

source§

impl Scalar for i64

§

type Raw = [u8; 8]

source§

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

source§

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

source§

impl Scalar for u8

§

type Raw = [u8; 1]

source§

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

source§

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

source§

impl Scalar for u16

§

type Raw = [u8; 2]

source§

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

source§

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

source§

impl Scalar for u32

§

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

§

type Raw = [u8; 2]

source§

impl Scalar for F4Dot12

§

type Raw = [u8; 2]

source§

impl Scalar for F6Dot10

§

type Raw = [u8; 2]

source§

impl Scalar for FWord

§

type Raw = [u8; 2]

source§

impl Scalar for Fixed

§

type Raw = [u8; 4]

source§

impl Scalar for GlyphId16

§

type Raw = [u8; 2]

source§

impl Scalar for LongDateTime

§

type Raw = [u8; 8]

source§

impl Scalar for MajorMinor

§

type Raw = [u8; 4]

source§

impl Scalar for NameId

§

type Raw = [u8; 2]

source§

impl Scalar for Offset16

§

type Raw = <u16 as Scalar>::Raw

source§

impl Scalar for Offset24

§

type Raw = <Uint24 as Scalar>::Raw

source§

impl Scalar for Offset32

§

type Raw = <u32 as Scalar>::Raw

source§

impl Scalar for Tag

§

type Raw = [u8; 4]

source§

impl Scalar for UfWord

§

type Raw = [u8; 2]

source§

impl Scalar for Uint24

§

type Raw = [u8; 3]

source§

impl Scalar for Version16Dot16

§

type Raw = [u8; 4]

source§

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

§

type Raw = <T as Scalar>::Raw