Skip to main content

OverlayGuard

Struct OverlayGuard 

Source
pub struct OverlayGuard { /* private fields */ }
Expand description

RAII owner of a shown overlay entry.

Dropping the guard dismisses the entry, so callers can’t leak entries by forgetting dismiss or mismatching a 0-sentinel id. The typical shape is a remember-ed RefCell<Option<OverlayGuard>>: set it to Some when the overlay should show, back to None to hide.

The guard holds only the handle + id (no entry content), so it never participates in reference cycles with the overlay state.

Implementations§

Source§

impl OverlayGuard

Source

pub fn show( handle: &OverlayHandle, builder: Rc<dyn Fn() -> View>, z_index: f32, pass_through: bool, ) -> Self

Show builder on handle and own the resulting entry.

Source

pub fn show_with_back( handle: &OverlayHandle, builder: Rc<dyn Fn() -> View>, z_index: f32, pass_through: bool, back_handler: BackHandler, ) -> Self

Source

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

Entry id, or None after dismiss.

Source

pub fn dismiss(self)

Dismiss now instead of at drop. Consuming the guard makes a double-dismiss impossible.

Trait Implementations§

Source§

impl Drop for OverlayGuard

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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> ErasedDestructor for T
where T: 'static,

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.