pub struct Message { /* private fields */ }
Expand description
A message box.
This dialog box displays a text and an optional title and has a single OK button. It does not produce any output.
§Example
use dialog::DialogBox;
dialog::Message::new("The operation was successful.")
.title("Success")
.show()
.expect("Could not display dialog box");
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(text: impl Into<String>) -> Message
pub fn new(text: impl Into<String>) -> Message
Creates a new message box with the given text.
Examples found in repository?
More examples
examples/backend-kdialog.rs (line 10)
7fn main() -> dialog::Result<()> {
8 let mut backend = backends::KDialog::new();
9
10 dialog::Message::new("This is a message.")
11 .title("And this is a title:")
12 .show_with(&backend)?;
13
14 backend.set_icon("error");
15 dialog::Message::new("This is an error message.")
16 .title("Error")
17 .show_with(&backend)
18}
examples/backend-dialog.rs (line 10)
7fn main() -> dialog::Result<()> {
8 let mut backend = backends::Dialog::new();
9
10 dialog::Message::new("This is a message.")
11 .title("And this is a title:")
12 .show_with(&backend)?;
13
14 backend.set_backtitle("Backtitle");
15 dialog::Message::new("This is a message.")
16 .title("And this is a title:")
17 .show_with(&backend)?;
18
19 backend.set_width(100);
20 backend.set_height(10);
21 dialog::Message::new("This is a message with a fixed size.")
22 .title("And this is a title:")
23 .show_with(&backend)
24}
examples/backend-zenity.rs (line 10)
7fn main() -> dialog::Result<()> {
8 let mut backend = backends::Zenity::new();
9
10 dialog::Message::new("This is a message.")
11 .title("And this is a title:")
12 .show_with(&backend)?;
13
14 backend.set_width(500);
15 backend.set_height(200);
16 dialog::Message::new("This is a message with a fixed size.")
17 .title("And this is a title:")
18 .show_with(&backend)?;
19
20 let mut backend = backends::Zenity::new();
21 backend.set_timeout(5);
22 dialog::Message::new("This box should disappear after five seconds.")
23 .title("And this is a title:")
24 .show_with(&backend)
25}
Sourcepub fn title(&mut self, title: impl Into<String>) -> &mut Message
pub fn title(&mut self, title: impl Into<String>) -> &mut Message
Sets the title of this message box.
This method returns a reference to self
to enable chaining.
Examples found in repository?
More examples
examples/backend-kdialog.rs (line 11)
7fn main() -> dialog::Result<()> {
8 let mut backend = backends::KDialog::new();
9
10 dialog::Message::new("This is a message.")
11 .title("And this is a title:")
12 .show_with(&backend)?;
13
14 backend.set_icon("error");
15 dialog::Message::new("This is an error message.")
16 .title("Error")
17 .show_with(&backend)
18}
examples/backend-dialog.rs (line 11)
7fn main() -> dialog::Result<()> {
8 let mut backend = backends::Dialog::new();
9
10 dialog::Message::new("This is a message.")
11 .title("And this is a title:")
12 .show_with(&backend)?;
13
14 backend.set_backtitle("Backtitle");
15 dialog::Message::new("This is a message.")
16 .title("And this is a title:")
17 .show_with(&backend)?;
18
19 backend.set_width(100);
20 backend.set_height(10);
21 dialog::Message::new("This is a message with a fixed size.")
22 .title("And this is a title:")
23 .show_with(&backend)
24}
examples/backend-zenity.rs (line 11)
7fn main() -> dialog::Result<()> {
8 let mut backend = backends::Zenity::new();
9
10 dialog::Message::new("This is a message.")
11 .title("And this is a title:")
12 .show_with(&backend)?;
13
14 backend.set_width(500);
15 backend.set_height(200);
16 dialog::Message::new("This is a message with a fixed size.")
17 .title("And this is a title:")
18 .show_with(&backend)?;
19
20 let mut backend = backends::Zenity::new();
21 backend.set_timeout(5);
22 dialog::Message::new("This box should disappear after five seconds.")
23 .title("And this is a title:")
24 .show_with(&backend)
25}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more