Skip to main content

SystemEnv

Struct SystemEnv 

Source
pub struct SystemEnv {
    pub appearance: Appearance,
    pub accent: Option<Color>,
    pub motion: MotionPref,
    pub locale: Option<Locale>,
    pub assistive: Assistive,
}
Expand description

The user’s OS settings, as the host reports them. Not window facts and not display facts: things the person chose once, in a settings app, that a view is expected to honour. The core acts on two of them in one way: appearance and accent derive the theme, so the stock widgets and a <text> with no colour follow the OS — and nothing else moves. Reduced motion does not shorten an animation and a dark appearance repaints none of the app’s own colours: the view decides, because only it knows which of its colours is the background and which of its animations carries meaning.

Each field defaults to “the host cannot tell”, which is what a headless core reports and what any driver reports for a fact its platform gives it no way to ask. The kui-native runner asks the OS for all four on macOS and Windows (the appearance through winit, the rest in its system_env); elsewhere it answers what it can and leaves the rest unknown. The fifth, Assistive, is not a setting but a fact of the same shape — the user chose to run a screen reader — and comes from the accessibility bridge rather than a settings query.

Fields§

§appearance: Appearance

Light or dark, when the host can tell.

§accent: Option<Color>

The OS accent/highlight colour, None when the host can’t tell.

§motion: MotionPref

Whether the user asked for reduced motion.

§locale: Option<Locale>

The UI language as a BCP-47 tag, None when the host can’t tell.

§assistive: Assistive

Whether assistive technology has asked for the access tree.

Implementations§

Source§

impl SystemEnv

Source

pub fn over(self, base: SystemEnv) -> SystemEnv

self laid over base: every field self knows wins, every field it left at “cannot tell” is base’s. The merge behind a launcher’s pinned reading (kui_native::Launcher::system, Node’s runWindowed(.., {system}), the context a C host hands kui_run_with): the app’s partial over what the OS answered, applied every frame where the runner writes the real reading — so a pinned motion survives the write, and a real change to the accent still arrives, because that field was left unknown here and base is the OS’s.

Unknown means not pinned, which is why there is no separate override type: the four “cannot tell” readings are the defaults, so SystemEnv { motion: MotionPref::Reduced, ..Default::default() } is the whole of “as if this user asked for less motion”. What it cannot say is “pin this to unknown” — a window on a platform that answers has no test that needs it.

Trait Implementations§

Source§

impl Clone for SystemEnv

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SystemEnv

Source§

impl Debug for SystemEnv

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SystemEnv

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for SystemEnv

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SystemEnv

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.