read_fonts::collections::int_set

Trait Domain

source
pub trait Domain: Sized {
    // Required methods
    fn to_u32(&self) -> u32;
    fn from_u32(member: InDomain) -> Self;
    fn is_continuous() -> bool;
    fn ordered_values() -> impl DoubleEndedIterator<Item = u32>;
    fn ordered_values_range(
        range: RangeInclusive<Self>,
    ) -> impl DoubleEndedIterator<Item = u32>;
    fn count() -> u64;
}
Expand description

Defines the domain of IntSet member types.

Members of IntSet must implement this trait. Members of IntSet’s must meet the following conditions to be used in an IntSet:

  1. Every possible unique value of T must be able map to and from a unique u32 integer.

  2. The mapped u32 values must retain the same ordering as the values in T.

  3. ordered_values() must iterate over all values in T in sorted order (ascending).

from_u32() will only ever be called with u32 values that are part of the domain of T as defined by an implementation of this trait. So it doesn’t need to correctly handle values that are outside the domain of T.

Required Methods§

source

fn to_u32(&self) -> u32

Converts this value of T to a value in u32.

The mapped value must maintain the same ordering as T.

source

fn from_u32(member: InDomain) -> Self

Converts a mapped u32 value back to T.

Will only ever be called with values produced by to_u32.

source

fn is_continuous() -> bool

Returns true if all u32 values between the mapped u32 min and mapped u32 max value of T are used.

source

fn ordered_values() -> impl DoubleEndedIterator<Item = u32>

Returns an iterator which iterates over all values in the domain of T

Values should be converted to u32’s according to the mapping defined in to_u32/from_u32.

source

fn ordered_values_range( range: RangeInclusive<Self>, ) -> impl DoubleEndedIterator<Item = u32>

Return an iterator which iterates over all values of T in the given range.

Values should be converted to u32’s according to the mapping defined in to_u32/from_u32.

source

fn count() -> u64

Returns the number of members in the domain.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Domain for u8

source§

impl Domain for u16

source§

impl Domain for u32

source§

impl Domain for GlyphId16

source§

impl Domain for GlyphId

source§

impl Domain for Tag

Implementors§