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)andrepr(C), and all fields are alsoFromBytes
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§
impl<T: Scalar> FromBytes for BigEndian<T>
impl FromBytes for u8
Implementors§
impl FromBytes for TableRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for AxisValueMap
SAFETY: see the FromBytes trait documentation.
impl FromBytes for BaseLangSysRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for BaseScriptRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for FeatMinMaxRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for ConstantMapGroup
SAFETY: see the FromBytes trait documentation.
impl FromBytes for EncodingRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for SequentialMapGroup
SAFETY: see the FromBytes trait documentation.
impl FromBytes for SubHeader
SAFETY: see the FromBytes trait documentation.
impl FromBytes for UnicodeRange
SAFETY: see the FromBytes trait documentation.
impl FromBytes for UvsMapping
SAFETY: see the FromBytes trait documentation.
impl FromBytes for VariationSelector
SAFETY: see the FromBytes trait documentation.
impl FromBytes for BaseGlyph
SAFETY: see the FromBytes trait documentation.
impl FromBytes for BaseGlyphPaint
SAFETY: see the FromBytes trait documentation.
impl FromBytes for Clip
SAFETY: see the FromBytes trait documentation.
impl FromBytes for ColorIndex
SAFETY: see the FromBytes trait documentation.
impl FromBytes for ColorStop
SAFETY: see the FromBytes trait documentation.
impl FromBytes for Layer
SAFETY: see the FromBytes trait documentation.
impl FromBytes for VarColorIndex
SAFETY: see the FromBytes trait documentation.
impl FromBytes for VarColorStop
SAFETY: see the FromBytes trait documentation.
impl FromBytes for ColorRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for VariationAxisRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for EntryExitRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for MarkRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for LongMetric
SAFETY: see the FromBytes trait documentation.
impl FromBytes for ClassRangeRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for FeatureRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for FeatureTableSubstitutionRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for FeatureVariationRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for LangSysRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for RangeRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for ScriptRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for SequenceLookupRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for ValueRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for LangTagRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for NameRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for FdSelectRange3
SAFETY: see the FromBytes trait documentation.
impl FromBytes for FdSelectRange4
SAFETY: see the FromBytes trait documentation.
impl FromBytes for AxisRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for AxisValueRecord
SAFETY: see the FromBytes trait documentation.
impl FromBytes for RegionAxisCoordinates
SAFETY: see the FromBytes trait documentation.