Struct zng_app::APP

source ·
pub struct APP;
Expand description

Start and manage an app process.

Implementations§

source§

impl APP

source

pub fn exit(&self) -> ResponseVar<ExitCancelled>

Register a request for process exit with code 0 in the next update.

The EXIT_REQUESTED_EVENT will notify, and if propagation is not cancelled the app process will exit.

Returns a response variable that is updated once with the unit value ExitCancelled if the exit operation is cancelled.

See also the EXIT_CMD.

source

pub fn is_suspended(&self) -> ReadOnlyArcVar<bool>

Gets a variable that tracks if the app is suspended by the operating system.

Suspended apps cannot create graphics contexts and are likely to be killed if the user does not return. Operations that persist data should flush on suspension.

App suspension is controlled by the view-process, the VIEW_PROCESS_SUSPENDED_EVENT notifies on suspension and the VIEW_PROCESS_INITED_EVENT notifies a “respawn” on resume.

source§

impl APP

App time control.

The manual time methods are only recommended for headless apps.

source

pub fn pause_time_for_update(&self) -> ArcVar<bool>

Gets a variable that configures if INSTANT.now is the same exact value during each update, info, layout or render pass.

Time is paused by default, setting this to false will cause INSTANT.now to read the system time for every call.

source

pub fn start_manual_time(&self)

Pause the INSTANT.now value, after this call it must be updated manually using advance_manual_time or set_manual_time. To resume normal time use end_manual_time.

source

pub fn advance_manual_time(&self, advance: Duration)

Adds the advance to the current manual time.

Note that you must ensure an update reaches the code that controls manual time, otherwise the app loop may end-up stuck on idle or awaiting a timer that never elapses.

§Panics

Panics if called before start_manual_time.

source

pub fn set_manual_time(&self, now: DInstant)

Set the current INSTANT.now.

§Panics

Panics if called before start_manual_time.

source

pub fn end_manual_time(&self)

Resumes normal time.

source§

impl APP

source

pub fn multi_app_enabled(&self) -> bool

If the crate was built with feature="multi_app".

If true multiple apps can run in the same process, but only one app per thread at a time.

source

pub fn is_running(&self) -> bool

If an app is already running in the current thread.

Apps are running as soon as they start building, and stop running after AppExtended::run returns or the HeadlessApp is dropped.

You can use app_local! to create static resources that live for the app lifetime.

source

pub fn id(&self) -> Option<AppId>

Gets the unique ID of the current app.

This ID usually does not change as most apps only run once per process, but it can change often during tests. Resources that interact with app_local! values can use this ID to ensure that they are still operating in the same app.

source

pub fn window_mode(&self) -> WindowMode

Returns a WindowMode value that indicates if the app is headless, headless with renderer or headed.

Note that specific windows can be in headless mode even if the app is headed.

source

pub fn extensions(&self) -> Arc<AppExtensionsInfo>

List of app extensions that are part of the current app.

source

pub fn device_events(&self) -> bool

If device events are enabled for the current app.

See AppExtension::enable_device_events for more details.

source§

impl APP

source

pub fn minimal(&self) -> AppExtended<Vec<Box<dyn AppExtensionBoxed>>>

Starts building an application with no extensions.

Auto Trait Implementations§

§

impl Freeze for APP

§

impl RefUnwindSafe for APP

§

impl Send for APP

§

impl Sync for APP

§

impl Unpin for APP

§

impl UnwindSafe for APP

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

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> StateValue for T
where T: Any + Send + Sync,