Skip to main content

cbf_compositor/model/
ids.rs

1/// Identifier for a compositor-managed native window attachment.
2#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
3pub struct CompositorWindowId(u64);
4
5impl CompositorWindowId {
6    /// Construct an identifier from its raw numeric value.
7    pub const fn new(raw: u64) -> Self {
8        Self(raw)
9    }
10
11    /// Return the raw numeric value.
12    pub const fn get(self) -> u64 {
13        self.0
14    }
15}
16
17impl std::fmt::Display for CompositorWindowId {
18    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19        write!(f, "{}", self.get())
20    }
21}
22
23/// Identifier for a scene item inside a compositor-managed window.
24#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
25pub struct CompositionItemId(u64);
26
27impl CompositionItemId {
28    /// Construct an identifier from its raw numeric value.
29    pub const fn new(raw: u64) -> Self {
30        Self(raw)
31    }
32
33    /// Return the raw numeric value.
34    pub const fn get(self) -> u64 {
35        self.0
36    }
37}
38
39impl std::fmt::Display for CompositionItemId {
40    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
41        write!(f, "{}", self.get())
42    }
43}