polyhorn_ui/assets/
image.rs

1use super::Asset;
2use crate::queries::ImageQuery;
3
4/// Static-typed asset for images.
5#[derive(Copy, Clone, Debug)]
6pub struct ImageAsset {
7    package: &'static str,
8    name: &'static str,
9    width: f32,
10    height: f32,
11}
12
13impl ImageAsset {
14    #[doc(hidden)]
15    pub fn new(package: &'static str, name: &'static str, width: f32, height: f32) -> ImageAsset {
16        ImageAsset {
17            package,
18            name,
19            width,
20            height,
21        }
22    }
23}
24
25impl PartialEq for ImageAsset {
26    fn eq(&self, other: &ImageAsset) -> bool {
27        self.package == other.package && self.name == other.name
28    }
29}
30
31impl Eq for ImageAsset {}
32
33impl Asset for ImageAsset {
34    fn package(&self) -> &str {
35        self.package
36    }
37
38    fn name(&self) -> &str {
39        self.name
40    }
41}
42
43impl ImageQuery for ImageAsset {
44    fn width(&self) -> f32 {
45        self.width
46    }
47
48    fn height(&self) -> f32 {
49        self.height
50    }
51}