pub trait DialogBox {
type Output;
// Required method
fn show_with<B>(&self, backend: impl AsRef<B>) -> Result<Self::Output>
where B: Backend + ?Sized;
// Provided method
fn show(&self) -> Result<Self::Output> { ... }
}
Expand description
A dialog box that can be shown using a backend.
Some dialog boxes might return data of the type Output
.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn show(&self) -> Result<Self::Output>
fn show(&self) -> Result<Self::Output>
Shows this dialog box using the default backend and returns the output.
box.show()
is a shorthand for box.show_with(default_backend())
.
Examples found in repository?
More examples
examples/input.rs (line 7)
6fn main() -> dialog::Result<()> {
7 let input1 = dialog::Input::new("Please enter something").show()?;
8 let input2 = dialog::Input::new("Please enter something")
9 .title("Input form")
10 .show()?;
11 let input3 = dialog::Input::new("Please enter something with a default")
12 .title("Input form")
13 .default("input")
14 .show()?;
15
16 println!("Input 1: {:?}", input1);
17 println!("Input 2: {:?}", input2);
18 println!("Input 3: {:?}", input3);
19 Ok(())
20}
examples/file_selection.rs (line 10)
6fn main() -> dialog::Result<()> {
7 let choice = dialog::FileSelection::new("Please select a file")
8 .title("File Chooser Example (Open)")
9 .path("/etc")
10 .show()?;
11 println!("The user chose: {:?}", choice);
12
13 let choice = dialog::FileSelection::new("Please select a file")
14 .title("File Chooser Example (Save)")
15 .mode(dialog::FileSelectionMode::Save)
16 .path("/etc")
17 .show()?;
18 println!("The user chose: {:?}", choice);
19
20 Ok(())
21}
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.