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§