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.

Object Safety§

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§