Skip to main content

Environment

Struct Environment 

Source
pub struct Environment {
Show 43 fields pub window: Size<Points>, pub horizontal_size_class: Option<SizeClass>, pub vertical_size_class: Option<SizeClass>, pub safe_area: EdgeInsets, pub reserved_regions: ReservedRegions, pub title_bar: Edges<Points>, pub window_state: Option<WindowState>, pub keyboard_height: Points, pub keyboard_duration: f32, pub dark: bool, pub font_scale: f32, pub reduce_motion: bool, pub screen_reader: bool, pub reads_active_descendants: bool, pub rtl: bool, pub pixel_ratio: f32, pub os: Os, pub platform: Option<&'static str>, pub os_version: (u16, u16), pub idiom: Idiom, pub locale: Locale, pub locale_settings: LocaleSettings, pub apple_keyboard: bool, pub ctrl_for_command: bool, pub host: bool, pub lifecycle: Lifecycle, pub wake_count: u32, pub network: Network, pub screen_color: bool, pub clipboard_write_result: bool, pub canvas_render: bool, pub app_settings: bool, pub scheme_links: bool, pub file_requests: bool, pub notifications: bool, pub audio: bool, pub tab_bar: bool, pub cell: Option<Size<Points>>, pub web_input: bool, pub web_evaluate: bool, pub web_views: bool, pub webview_requests: bool, pub shaders: bool,
}
Expand description

The environment of a surface, as the platform reports it.

Fields§

§window: Size<Points>

The surface’s size in points.

§horizontal_size_class: Option<SizeClass>

Native horizontal size class, or None to use the window width at 600pt.

§vertical_size_class: Option<SizeClass>

Native vertical size class, or None to use the window height at 600pt.

§safe_area: EdgeInsets

The edges system UI covers.

§reserved_regions: ReservedRegions

The parts of the surface the device reserves (crate::platform::Environment::reserved_regions).

§title_bar: Edges<Points>

Space reserved for system controls in a custom desktop title bar.

§window_state: Option<WindowState>

The app’s window: its bounds, mode and display (desktops).

§keyboard_height: Points

The software keyboard’s height, 0 when hidden.

§keyboard_duration: f32

How long the keyboard’s show / hide animation takes, in milliseconds.

§dark: bool

Dark appearance.

§font_scale: f32

The user’s text size relative to the default.

§reduce_motion: bool

Less motion asked for.

§screen_reader: bool

A screen reader runs.

§reads_active_descendants: bool

The platform’s screen readers follow active descendants (crate::platform::Environment::reads_active_descendants).

§rtl: bool

Right-to-left layout.

§pixel_ratio: f32

Device pixels per point.

§os: Os

The operating system.

§platform: Option<&'static str>

The platform’s name where it is not the OS’s (a platform built outside NSH: crate::platform::Environment::platform).

§os_version: (u16, u16)

The OS version: major and minor (iOS), Android’s API level and 0.

§idiom: Idiom

The kind of device.

§locale: Locale

The user’s locale, for formatting numbers and dates.

§locale_settings: LocaleSettings

The user’s locale settings: the preferred languages, the time zone and the regional preferences.

§apple_keyboard: bool

In a browser, it runs on an Apple platform: shortcuts follow Apple’s conventions (crate::keymap::apple_keys); the other OSes imply theirs.

§ctrl_for_command: bool

Ctrl stands in for Command: labels show Command as Ctrl (crate::platform::Environment::ctrl_for_command).

§host: bool

The embedding app answers nsh/host’s calls (crate::platform::Environment::host).

§lifecycle: Lifecycle

Whether the app is in use: in the foreground, visible without the focus, or in the background.

§wake_count: u32

How many times the system woke from sleep while the surface ran (crate::platform::Environment::wake_count).

§network: Network

How the device reaches the network (crate::platform::Environment::network).

§screen_color: bool

The platform picks colors from the screen (crate::platform::Environment::screen_color).

§clipboard_write_result: bool

The platform reports clipboard writes’ results (crate::platform::Environment::clipboard_write_result).

§canvas_render: bool

The platform renders canvas drawings offscreen into images (crate::platform::Environment::canvas_render).

§app_settings: bool

The platform opens the app’s page in the system’s settings (crate::platform::Environment::app_settings).

§scheme_links: bool

Links of the schemes the app claims reach it (crate::platform::Environment::scheme_links, resolved: true on every OS but the web unless the platform says otherwise).

§file_requests: bool

The platform shows file dialogs and opens, reveals and trashes local paths (crate::platform::Environment::file_requests).

§notifications: bool

The platform shows notifications (crate::platform::Environment::notifications).

§audio: bool

The platform plays sound (crate::platform::Environment::audio).

§tab_bar: bool

The platform shows the system’s tab bar on iOS and Android (crate::platform::Environment::tab_bar).

§cell: Option<Size<Points>>

The Cell size of a grid surface (a terminal): the core lays out in its Cells (crate::platform::Environment::cell); None elsewhere.

§web_input: bool

The platform gives web views trusted input (crate::platform::Environment::web_input).

§web_evaluate: bool

The platform answers awaitable WebView evaluations (crate::Command::Evaluate); false rejects as unavailable.

§web_views: bool

The platform shows web views (crate::platform::Environment::web_views).

§webview_requests: bool

The platform carries out web view requests (crate::platform::Environment::webview_requests).

§shaders: bool

The platform draws shader views (crate::platform::Environment::shaders).

Implementations§

Source§

impl Environment

Source

pub fn platform_name(&self) -> &'static str

The platform’s name (TS: platform.name): a platform built outside NSH’s own, else the OS’s.

Trait Implementations§

Source§

impl Clone for Environment

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 Environment

Source§

impl Debug for Environment

Source§

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

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

impl Default for Environment

Source§

fn default() -> Self

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

impl PartialEq for Environment

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 Environment

Auto Trait Implementations§

§

impl Forget for Environment

§

impl Freeze for Environment
where &'static str: Freeze,

§

impl Move for Environment

§

impl RefUnwindSafe for Environment

§

impl Send for Environment
where &'static str: Send,

§

impl Sync for Environment

§

impl Unpin for Environment
where &'static str: Unpin,

§

impl UnsafeUnpin for Environment
where &'static str: UnsafeUnpin,

§

impl UnwindSafe for Environment
where &'static str: UnwindSafe,

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<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> Same for T

Source§

type Output = T

Should always be Self
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.