Struct AccessibilityLayer
pub struct AccessibilityLayer {
pub schema_version: u32,
pub high_contrast: bool,
pub forced_colors: bool,
pub text_scale: f32,
pub ui_scale: f32,
pub reduce_motion: bool,
pub reduce_transparency: bool,
pub thick_caret: bool,
pub hyperlegible: bool,
pub distinct_letters: Option<bool>,
}Expand description
Accessibility layer. Nothing below it can lower contrast, shrink text, or turn motion back on.
schema_version is admitted by Self::validate before the layer
changes a theme. Text and UI scales outside the usable band are clamped
in Self::materialize, which is what resolve_theme_layers applies.
Fields§
§schema_version: u32§high_contrast: bool§forced_colors: bool§text_scale: f32Multiplier for type only. Usable band is
Self::TEXT_SCALE_MIN..=Self::TEXT_SCALE_MAX.
ui_scale: f32Multiplier for spacing, radii, and type together.
reduce_motion: bool§reduce_transparency: boolFloating chrome is opaque instead of blurred and tinted.
thick_caret: bool§hyperlegible: boolSet the UI in the Hyperlegible face (crate::tokens::UiFace)
whatever face the theme chose.
distinct_letters: Option<bool>“Always distinguish similar letters”: I, l, 1 and 0, O set apart in
all text. None keeps the theme’s choice
(crate::theme::ThemeType::distinguishes_letters: on with
Hyperlegible, including the Hyperlegible this layer chooses).
Implementations§
§impl AccessibilityLayer
impl AccessibilityLayer
pub const TEXT_SCALE_MIN: f32 = 0.5
pub const TEXT_SCALE_MIN: f32 = 0.5
Same lower bound as Theme::with_text_scale.
pub const TEXT_SCALE_MAX: f32 = 4.0
pub const TEXT_SCALE_MAX: f32 = 4.0
Same upper bound as Theme::with_text_scale.
pub const UI_SCALE_MIN: f32 = 0.5
pub const UI_SCALE_MIN: f32 = 0.5
Same lower bound as Theme::with_ui_scale.
pub const UI_SCALE_MAX: f32 = 3.0
pub const UI_SCALE_MAX: f32 = 3.0
Same upper bound as Theme::with_ui_scale.
pub fn validate(&self) -> Result<(), &'static str>
pub fn validate(&self) -> Result<(), &'static str>
Structural check. A failure means this layer is not applied.
Schema versions outside
[ACCESSIBILITY_SCHEMA_MIN]..=[ACCESSIBILITY_SCHEMA_VERSION]
are rejected, as is a non-finite scale. A finite scale outside the
usable band is clamped by Self::materialize, not rejected.
§Errors
Returns a static message when the schema is outside the admitted range or a scale is not finite.
pub fn materialize(&self) -> Result<AccessibilityLayer, &'static str>
pub fn materialize(&self) -> Result<AccessibilityLayer, &'static str>
Self::validate, then clamp scales into the usable band.
The returned scales are what resolution applies. The raw payload is
not handed to Theme::with_text_scale or Theme::with_ui_scale.
§Errors
The same static message as Self::validate.
Trait Implementations§
§impl Clone for AccessibilityLayer
impl Clone for AccessibilityLayer
§fn clone(&self) -> AccessibilityLayer
fn clone(&self) -> AccessibilityLayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for AccessibilityLayer
impl Debug for AccessibilityLayer
§impl Default for AccessibilityLayer
impl Default for AccessibilityLayer
§fn default() -> AccessibilityLayer
fn default() -> AccessibilityLayer
§impl<'de> Deserialize<'de> for AccessibilityLayer
impl<'de> Deserialize<'de> for AccessibilityLayer
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AccessibilityLayer, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AccessibilityLayer, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl PartialEq for AccessibilityLayer
impl PartialEq for AccessibilityLayer
§fn eq(&self, other: &AccessibilityLayer) -> bool
fn eq(&self, other: &AccessibilityLayer) -> bool
self and other values to be equal, and is used by ==.§impl Serialize for AccessibilityLayer
impl Serialize for AccessibilityLayer
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for AccessibilityLayer
impl StructuralPartialEq for AccessibilityLayer
Auto Trait Implementations§
impl Freeze for AccessibilityLayer
impl RefUnwindSafe for AccessibilityLayer
impl Send for AccessibilityLayer
impl Sync for AccessibilityLayer
impl Unpin for AccessibilityLayer
impl UnsafeUnpin for AccessibilityLayer
impl UnwindSafe for AccessibilityLayer
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more