# Trait Domain

    pub trait Domain: Sized + Copy {
        // Required methods
        fn to_u32(&self) -> u32;
        fn contains(value: u32) -> bool;
        fn from_u32(member: InDomain) -> Self;
        fn is_continuous() -> bool;
        fn ordered_values() -> impl DoubleEndedIterator;
        fn ordered_values_range(
            range: RangeInclusive<Self>,
        ) -> impl DoubleEndedIterator;
        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§

#### 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`.

#### fn contains(value: u32) -> bool

Returns `true` if the value is part of this domain.

#### 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`.

#### fn is_continuous() -> bool

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

#### fn ordered_values() -> impl DoubleEndedIterator

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`.

#### fn ordered_values_range(range: RangeInclusive<Self>) -> impl DoubleEndedIterator

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`.

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

§

### impl Domain for u8

§

#### fn to_u32(&self) -> u32

§

#### fn from_u32(member: InDomain) -> u8

§

#### fn contains(value: u32) -> bool

§

#### fn is_continuous() -> bool

§

#### fn ordered_values() -> impl DoubleEndedIterator

§

#### fn ordered_values_range(range: RangeInclusive<u8>) -> impl DoubleEndedIterator

§

#### fn count() -> u64

§

### impl Domain for u16

§

#### fn to_u32(&self) -> u32

§

#### fn from_u32(member: InDomain) -> u16

§

#### fn contains(value: u32) -> bool

§

#### fn is_continuous() -> bool

§

#### fn ordered_values() -> impl DoubleEndedIterator

§

#### fn ordered_values_range(range: RangeInclusive<u16>) -> impl DoubleEndedIterator

§

#### fn count() -> u64

§

### impl Domain for u32

§

#### fn to_u32(&self) -> u32

§

#### fn from_u32(member: InDomain) -> u32

§

#### fn contains(_value: u32) -> bool

§

#### fn is_continuous() -> bool

§

#### fn ordered_values() -> impl DoubleEndedIterator

§

#### fn ordered_values_range(range: RangeInclusive<u32>) -> impl DoubleEndedIterator

§

#### fn count() -> u64

## Implementors§

§

### impl Domain for NameId

§

### impl Domain for GlyphId16

§

### impl Domain for GlyphId

§

### impl Domain for Tag