Skip to main content

SceneHandle

Struct SceneHandle 

Source
pub struct SceneHandle(/* private fields */);
Expand description

A value conforming to SwiftUI’s Scene — a window, a settings pane, a menu-bar item, or a tuple of them.

Implementations§

Source§

impl SceneHandle

Source

pub fn type_name(&self) -> String

The Swift type of the scene, as the runtime spells it.

Examples found in repository?
examples/scenes.rs (line 291)
282fn main() {
283    // `--describe` asks the same question the event loop would and prints the
284    // answer: what Swift types came out of this. Useful because the types are
285    // the claim — `_TupleScene<(WindowGroup<AnyView>, Settings<AnyView>, …)>` is
286    // what Swift builds from four scenes in a row, and nothing about a window
287    // appearing would say whether that is what got built.
288    #[cfg(target_os = "macos")]
289    if std::env::args().any(|a| a == "--describe") {
290        let whole = body();
291        println!("App.Body\n  {}", whole.type_name());
292        for (name, s) in [
293            ("window_group", scene::window_group(main_window)),
294            ("settings", scene::settings(settings_pane)),
295            ("window", scene::window("Utility", "utility", utility_window)),
296            ("menu_bar_extra", scene::menu_bar_extra("Count", "star.fill", menu_bar_item)),
297        ] {
298            println!("{name}\n  {}", s.type_name());
299        }
300        // Built through the macro, so this also checks that what `scenes!`
301        // expands to is the same thing the free functions build.
302        let one = scenes! { window_group { text("x") } commands { menu("M") { text("x") } } };
303        println!("scenes! with one menu\n  {}", one.type_name());
304        return;
305    }
306
307    // `--probe` launches for real and reports what AppKit built, then quits.
308    #[cfg(target_os = "macos")]
309    if std::env::args().any(|a| a == "--probe") {
310        probe::schedule(2.5);
311    }
312
313    app::run_scene(body)
314}

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