Debian Codegraph @

examples/images.rs

raw symbols SCIP
1 #![allow(unused_imports)]
2
3 use notify_rust::Hint;
4 #[cfg(all(feature = "images_no_default_features", unix, not(target_os = "macos")))]
5 use notify_rust::Image;
6 use notify_rust::Notification;
7
8 #[cfg(any(target_os = "windows", target_os = "macos"))]
9 fn main() {
10 println!("this is a xdg only feature")
11 }
12
13 #[cfg(all(
14 not(feature = "images_no_default_features"),
15 unix,
16 not(target_os = "macos")
17 ))]
18 fn main() {
19 println!("please build with '--features=images'")
20 }
21
22 #[cfg(all(
23 feature = "images_no_default_features",
24 unix,
25 not(target_os = "macos"),
26 not(target_os = "windows")
27 ))]
28 fn main() -> Result<(), Box<dyn std::error::Error>> {
29 fn image_data() -> Vec<u8> {
30 let mut image_data = vec![0; 128 * 128 * 3];
31 for i in 0..128 * 128 * 3 {
32 image_data[i] = (i % 256) as u8;
33 }
34 image_data
35 }
36
37 Notification::new()
38 .summary("Generated Image (.hint())")
39 .body("You should see stripes in this notification")
40 .hint(Hint::ImageData(Image::from_rgb(128, 128, image_data())?))
41 .show()?;
42
43 Notification::new()
44 .summary("Generated Image (.image_data())")
45 .body("You should see stripes in this notification")
46 .image_data(Image::from_rgb(128, 128, image_data())?)
47 .show()?;
48
49 Notification::new()
50 .summary(".image()")
51 .body("Trying to open an image")
52 .image("./examples/octodex.jpg")?
53 .show()?;
54
55 Notification::new()
56 .summary(".image_path()")
57 .body("Trying to open an image")
58 .image_path("./examples/octodex.jpg")
59 .show()?;
60
61 Ok(())
62 }