# Trait Scalar

    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§

#### type Raw: BeByteArray

The raw byte representation of this type.

## Required Methods§

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

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

#### fn to_raw(self) -> Self::Raw

Encode this type as raw big-endian bytes

## Provided Methods§

#### 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§

§

### impl Scalar for i8

§

#### type Raw = [u8; 1]

§

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

§

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

§

### impl Scalar for i16

§

#### type Raw = [u8; 2]

§

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

§

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

§

### impl Scalar for i32

§

#### type Raw = [u8; 4]

§

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

§

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

§

### impl Scalar for i64

§

#### type Raw = [u8; 8]

§

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

§

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

§

### impl Scalar for u8

§

#### type Raw = [u8; 1]

§

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

§

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

§

### impl Scalar for u16

§

#### type Raw = [u8; 2]

§

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

§

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

§

### impl Scalar for u32

§

#### type Raw = [u8; 4]

§

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

§

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

## Implementors§

§

### impl Scalar for CompositeMode

§

#### type Raw = <u8 as Scalar>::Raw

§

### impl Scalar for Extend

§

#### type Raw = <u8 as Scalar>::Raw

§

### impl Scalar for PlatformId

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for GlyphClassDef

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for DeltaFormat

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for NameId

§

#### type Raw = [u8; 2]

§

### impl Scalar for GlyphId16

§

#### type Raw = [u8; 2]

§

### impl Scalar for Tag

§

#### type Raw = [u8; 4]

§

### impl Scalar for BitmapFlags

§

#### type Raw = <u8 as Scalar>::Raw

§

### impl Scalar for PaletteType

§

#### type Raw = <u32 as Scalar>::Raw

§

### impl Scalar for PermissionFlags

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for GaspRangeBehavior

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for CompositeGlyphFlags

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for SimpleGlyphFlags

§

#### type Raw = <u8 as Scalar>::Raw

§

### impl Scalar for ValueFormat

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for GvarFlags

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for Flags

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for MacStyle

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for LookupFlag

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for SelectionFlags

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for HeaderFlags

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for AxisValueTableFlags

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for VarcFlags

§

#### type Raw = <u32 as Scalar>::Raw

§

### impl Scalar for EntryFormat

§

#### type Raw = <u8 as Scalar>::Raw

§

### impl Scalar for TupleIndex

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for TupleVariationCount

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for F2Dot14

§

#### type Raw = [u8; 2]

§

### impl Scalar for F4Dot12

§

#### type Raw = [u8; 2]

§

### impl Scalar for F6Dot10

§

#### type Raw = [u8; 2]

§

### impl Scalar for FWord

§

#### type Raw = [u8; 2]

§

### impl Scalar for Fixed

§

#### type Raw = [u8; 4]

§

### impl Scalar for Int24

§

#### type Raw = [u8; 3]

§

### impl Scalar for LongDateTime

§

#### type Raw = [u8; 8]

§

### impl Scalar for MajorMinor

§

#### type Raw = [u8; 4]

§

### impl Scalar for Offset16

§

#### type Raw = <u16 as Scalar>::Raw

§

### impl Scalar for Offset24

§

#### type Raw = <Uint24 as Scalar>::Raw

§

### impl Scalar for Offset32

§

#### type Raw = <u32 as Scalar>::Raw

§

### impl Scalar for UfWord

§

#### type Raw = [u8; 2]

§

### impl Scalar for Uint24

§

#### type Raw = [u8; 3]

§

### impl Scalar for Version16Dot16

§

#### type Raw = [u8; 4]

§

### impl<T> Scalar for Nullable<T>
where T: Scalar,

§

#### type Raw = <T as Scalar>::Raw