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
use super::Asset;
use crate::queries::ImageQuery;

/// Static-typed asset for images.
#[derive(Copy, Clone, Debug)]
pub struct ImageAsset {
    package: &'static str,
    name: &'static str,
    width: f32,
    height: f32,
}

impl ImageAsset {
    #[doc(hidden)]
    pub fn new(package: &'static str, name: &'static str, width: f32, height: f32) -> ImageAsset {
        ImageAsset {
            package,
            name,
            width,
            height,
        }
    }
}

impl PartialEq for ImageAsset {
    fn eq(&self, other: &ImageAsset) -> bool {
        self.package == other.package && self.name == other.name
    }
}

impl Eq for ImageAsset {}

impl Asset for ImageAsset {
    fn package(&self) -> &str {
        self.package
    }

    fn name(&self) -> &str {
        self.name
    }
}

impl ImageQuery for ImageAsset {
    fn width(&self) -> f32 {
        self.width
    }

    fn height(&self) -> f32 {
        self.height
    }
}