Skip to main content

Dialogs

Struct Dialogs 

Source
pub struct Dialogs<T> {
    shower: Rc<dyn ShowDialog>,
    waker: Arc<dyn Waker>,
    asked: RefCell<Vec<(FileDialog, T)>>,
    answers: Rc<RefCell<VecDeque<(T, Picked)>>>,
}
Expand description

The dialogs an app has asked for, and the answers that have come back. T says where each answer goes, in whatever terms the app uses.

Fields§

§shower: Rc<dyn ShowDialog>§waker: Arc<dyn Waker>§asked: RefCell<Vec<(FileDialog, T)>>§answers: Rc<RefCell<VecDeque<(T, Picked)>>>

Implementations§

Source§

impl<T: 'static> Dialogs<T>

Source

pub fn new(shower: Rc<dyn ShowDialog>, waker: Arc<dyn Waker>) -> Self

waker asks the UI thread to call Dialogs::show_asked and then, inside an event, Dialogs::receive.

Source

pub fn ask(&self, dialog: FileDialog, target: T)

Asks for dialog, to be shown once the current event has finished.

Source

pub fn show_asked(&self)

Shows every dialog asked for since the last call. Call it from the waker’s handler outside any event: a platform may run a modal loop here, which handles other events.

Source

pub fn receive<E>( &self, apply: impl FnMut(&T, Picked) -> Result<(), E>, ) -> Result<(), E>

Hands each answer that has come back to apply with where it goes. Stops at the first error, leaving later answers queued.

§Errors

The first error apply returns.

Trait Implementations§

Source§

impl<T> Debug for Dialogs<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for Dialogs<T>

§

impl<T> !RefUnwindSafe for Dialogs<T>

§

impl<T> !Send for Dialogs<T>

§

impl<T> !Sync for Dialogs<T>

§

impl<T> !UnwindSafe for Dialogs<T>

§

impl<T> Unpin for Dialogs<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Dialogs<T>

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