iced_beacon/
span.rs

1use crate::core::window;
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub enum Span {
7    Boot,
8    Update {
9        number: usize,
10        message: String,
11        tasks: usize,
12        subscriptions: usize,
13    },
14    View {
15        window: window::Id,
16    },
17    Layout {
18        window: window::Id,
19    },
20    Interact {
21        window: window::Id,
22    },
23    Draw {
24        window: window::Id,
25    },
26    Present {
27        window: window::Id,
28        prepare: present::Stage,
29        render: present::Stage,
30        layers: usize,
31    },
32    Custom {
33        name: String,
34    },
35}
36
37#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
38pub enum Stage {
39    Boot,
40    Update,
41    View(window::Id),
42    Layout(window::Id),
43    Interact(window::Id),
44    Draw(window::Id),
45    Present(window::Id),
46    Prepare(present::Primitive),
47    Render(present::Primitive),
48    Custom(String),
49}
50
51impl std::fmt::Display for Stage {
52    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
53        f.write_str(match self {
54            Stage::Boot => "Boot",
55            Stage::Update => "Update",
56            Stage::View(_) => "View",
57            Stage::Layout(_) => "Layout",
58            Stage::Interact(_) => "Interact",
59            Stage::Draw(_) => "Draw",
60            Stage::Prepare(_) => "Prepare",
61            Stage::Render(_) => "Render",
62            Stage::Present(_) => "Present",
63            Stage::Custom(name) => name,
64        })
65    }
66}
67
68pub mod present {
69    use crate::core::time::Duration;
70
71    use serde::{Deserialize, Serialize};
72
73    #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
74    pub struct Stage {
75        pub quads: Duration,
76        pub triangles: Duration,
77        pub shaders: Duration,
78        pub text: Duration,
79        pub images: Duration,
80    }
81
82    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
83    pub enum Primitive {
84        Quad,
85        Triangle,
86        Shader,
87        Text,
88        Image,
89    }
90}