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(
38    Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
39)]
40pub enum Stage {
41    Boot,
42    Update,
43    View(window::Id),
44    Layout(window::Id),
45    Interact(window::Id),
46    Draw(window::Id),
47    Present(window::Id),
48    Prepare(present::Primitive),
49    Render(present::Primitive),
50    Custom(String),
51}
52
53impl std::fmt::Display for Stage {
54    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
55        f.write_str(match self {
56            Stage::Boot => "Boot",
57            Stage::Update => "Update",
58            Stage::View(_) => "View",
59            Stage::Layout(_) => "Layout",
60            Stage::Interact(_) => "Interact",
61            Stage::Draw(_) => "Draw",
62            Stage::Prepare(_) => "Prepare",
63            Stage::Render(_) => "Render",
64            Stage::Present(_) => "Present",
65            Stage::Custom(name) => name,
66        })
67    }
68}
69
70pub mod present {
71    use crate::core::time::Duration;
72
73    use serde::{Deserialize, Serialize};
74
75    #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
76    pub struct Stage {
77        pub quads: Duration,
78        pub triangles: Duration,
79        pub shaders: Duration,
80        pub text: Duration,
81        pub images: Duration,
82    }
83
84    #[derive(
85        Debug,
86        Clone,
87        Copy,
88        PartialEq,
89        Eq,
90        PartialOrd,
91        Ord,
92        Hash,
93        Serialize,
94        Deserialize,
95    )]
96    pub enum Primitive {
97        Quad,
98        Triangle,
99        Shader,
100        Text,
101        Image,
102    }
103}