Trait read_fonts::FromBytes

source ·
pub unsafe trait FromBytes: FixedSize + Sealed { }
Expand description

A marker trait for types that can read from a big-endian buffer without copying.

This is used as a trait bound on certain methods on FontData (such as FontData::read_ref_at and FontData::read_array) in order to ensure that those methods are only used with types that uphold certain safety guarantees.

WARNING: Do not implement this trait manually. Implementations are created where appropriate during code generation, and there should be no conditions under which this trait could be implemented, but cannot be implemented by codegen.

Safety

If a type T implements FromBytes then unsafe code may assume that it is safe to interpret any sequence of bytes with length equal to std::mem::size_of::<T>() as T.

we additionally ensure the following conditions:

  • the type must have no internal padding
  • std::mem::align_of::<T>() == 1
  • for structs, the type is repr(packed) and repr(C), and all fields are also FromBytes

In practice, this trait is only implemented for u8, BigEndian<T>, and for structs where all fields are those base types.

Implementations on Foreign Types§

source§

impl<T: Scalar> FromBytes for BigEndian<T>

source§

impl FromBytes for u8

Implementors§

source§

impl FromBytes for TableRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for AxisValueMap

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for BaseLangSysRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for BaseScriptRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for FeatMinMaxRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for ConstantMapGroup

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for EncodingRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for SequentialMapGroup

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for SubHeader

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for UnicodeRange

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for UvsMapping

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for VariationSelector

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for BaseGlyph

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for BaseGlyphPaint

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for Clip

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for ColorIndex

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for ColorStop

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for Layer

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for VarColorIndex

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for VarColorStop

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for ColorRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for VariationAxisRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for EntryExitRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for MarkRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for LongMetric

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for ClassRangeRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for FeatureRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for FeatureTableSubstitutionRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for FeatureVariationRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for LangSysRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for RangeRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for ScriptRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for SequenceLookupRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for ValueRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for LangTagRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for NameRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for FdSelectRange3

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for FdSelectRange4

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for AxisRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for AxisValueRecord

SAFETY: see the FromBytes trait documentation.

source§

impl FromBytes for RegionAxisCoordinates

SAFETY: see the FromBytes trait documentation.