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;
}
Available on crate feature std only.
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.

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