FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    ClassicDesktopStyleApplicationLifetime

    struct · ferroui-controls · v0.5.0

    struct ClassicDesktopStyleApplicationLifetime
    

    The application lifetime of classic desktop applications: it tracks the open windows, shuts the application down according to its ShutdownMode and runs the main loop where the platform has one.

    Ownership

    The lifetime is a shared handle (Rc). Once it has been set up it is kept alive by the window class handlers it registers, by the platform lifetime events it subscribes to and by the application it is the lifetime of (which the service locator holds), so nothing depends on the stack frame of the caller of start. Call dispose to release those subscriptions.

    View source

    Members

    new

    fn new() -> Rc<Self>
    

    Creates a lifetime without arguments, with the default shutdown mode and without a main window.

    Source

    startup

    fn startup(self: &Self, handler: impl Fn(&ControlledApplicationLifetimeStartupEventArgs) -> () + 'static) -> Subscription
    

    Raised when the application is starting. Dropping the returned guard removes the handler; Subscription::detach keeps it for the life of the lifetime.

    Source

    shutdown_requested

    fn shutdown_requested(self: &Self, handler: impl Fn(&ShutdownRequestedEventArgs) -> () + 'static) -> Subscription
    

    Raised when an application shutdown is requested; see IClassicDesktopStyleApplicationLifetime::shutdown_requested. Dropping the returned guard removes the handler; Subscription::detach keeps it for the life of the lifetime.

    Source

    exit

    fn exit(self: &Self, handler: impl Fn(&ControlledApplicationLifetimeExitEventArgs) -> () + 'static) -> Subscription
    

    Raised when the application is exiting. Dropping the returned guard removes the handler; Subscription::detach keeps it for the life of the lifetime.

    Source

    args

    fn args(self: &Self) -> Option<Vec<String>>
    

    The arguments passed to the builder's start method.

    Source

    set_args

    fn set_args(self: &Self, value: Option<Vec<String>>)
    

    Sets the arguments of the application.

    Source

    shutdown_mode

    fn shutdown_mode(self: &Self) -> ShutdownMode
    

    The shutdown mode; see IClassicDesktopStyleApplicationLifetime::shutdown_mode.

    Source

    set_shutdown_mode

    fn set_shutdown_mode(self: &Self, value: ShutdownMode)
    

    Sets the shutdown mode.

    Source

    main_window

    fn main_window(self: &Self) -> Option<Ref<Window>>
    

    The main window of the application.

    Source

    set_main_window

    fn set_main_window(self: &Self, value: Option<Ref<Window>>)
    

    Sets the main window of the application.

    Source

    windows

    fn windows(self: &Self) -> Vec<Ref<Window>>
    

    The list of all open windows in the application, in the order they were opened.

    Source

    shutdown

    fn shutdown(self: &Self, exit_code: i32)
    

    Shuts down the application and sets the exit code that is returned to the operating system. Windows cannot cancel this shutdown and the shutdown requested event is not raised.

    Source

    try_shutdown

    fn try_shutdown(self: &Self, exit_code: i32) -> bool
    

    Tries to shut down the application; the shutdown requested event and the closing event of the windows can cancel the shutdown. Returns whether the application shuts down.

    Panics

    Panics when the application is already shutting down.

    Source

    start

    fn start(self: &Self, args: &[String]) -> i32
    

    Starts the application: raises the startup event with args and shows the main window, then

    • where the dispatcher of the UI thread supports run loops (Dispatcher::supports_run_loops), runs the main loop until the application shuts down and returns the exit code of the shutdown;
    • otherwise (platforms whose event loop is owned by the host, such as a browser) returns immediately with the exit code as it is at that moment: 0, or the code of a shutdown that happened while the main window was shown. The application keeps running, driven by the host; a later shutdown or try_shutdown closes the windows, raises the exit event (which carries the exit code) and shuts the dispatcher down exactly as it does on the platforms with a loop.

    Source

    start_with_own_args

    fn start_with_own_args(self: &Self) -> i32
    

    start with the arguments the lifetime was prepared with (args), for integrating with hosts that manage the lifetime themselves.

    Source

    dispose

    fn dispose(self: &Self)
    

    Stops tracking windows and listening to the platform's shutdown requests.

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.