1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

pub trait Handle {
    fn get_handle(&self) -> u32;
}

pub enum DrawableHandle {
    Texture(CanvasTextureHandle),
    Image(CanvasImageHandle),
    Font(CanvasFontHandle),
}

/// Typed wrapper for a u32 handle
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasFontHandle {
    pub(in crate::canvas) handle: u32
}

impl Handle for CanvasFontHandle {
    fn get_handle(&self) -> u32 {
        self.handle
    }
}

/// Typed wrapper for a u32 handle
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasTextureHandle {
    pub/*(in crate::canvas)*/ handle: u32
}

impl Handle for CanvasTextureHandle {
    fn get_handle(&self) -> u32 {
        self.handle
    }
}

/// Typed wrapper for a u32 handle
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CanvasImageHandle {
    pub(in crate::canvas) handle: u32
}

impl Handle for CanvasImageHandle {
    fn get_handle(&self) -> u32 {
        self.handle
    }
}

/// Typed wrapper for a u32 handle
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct CompiledShaderHandle {
    pub(in crate::canvas) handle: u32
}

impl Handle for CompiledShaderHandle {
    fn get_handle(&self) -> u32 {
        self.handle
    }
}