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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
use super::{IconDir, IconSizeType};
use std::{
borrow::Borrow,
path::{Path, PathBuf},
sync::Arc,
};
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub enum IconFileType {
PNG,
SVG,
XPM,
}
impl IconFileType {
pub(crate) const fn types() -> &'static [IconFileType; 3] {
const TYPES: [IconFileType; 3] = [IconFileType::PNG, IconFileType::SVG, IconFileType::XPM];
&TYPES
}
}
impl AsRef<str> for IconFileType {
fn as_ref(&self) -> &'static str {
match self {
IconFileType::PNG => "png",
IconFileType::SVG => "svg",
IconFileType::XPM => "xpm",
}
}
}
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct IconFile {
dir_info: Arc<IconDir>,
path: PathBuf,
icon_type: IconFileType,
}
impl IconFile {
pub fn dir_info(&self) -> &IconDir {
&self.dir_info
}
pub fn path(&self) -> &Path {
&self.path
}
pub const fn icon_type(&self) -> IconFileType {
self.icon_type
}
pub fn size(&self) -> u16 {
self.dir_info.size()
}
pub fn scale(&self) -> u16 {
self.dir_info.scale()
}
pub fn context(&self) -> Option<&str> {
self.dir_info.context()
}
pub fn size_type(&self) -> IconSizeType {
self.dir_info.size_type()
}
pub fn max_size(&self) -> u16 {
self.dir_info.max_size()
}
pub fn min_size(&self) -> u16 {
self.dir_info.min_size()
}
pub fn threshold(&self) -> u16 {
self.dir_info.threshold()
}
pub(crate) const fn new(
dir_info: Arc<IconDir>,
path: PathBuf,
icon_type: IconFileType,
) -> Self {
Self {
dir_info,
path,
icon_type,
}
}
}
impl AsRef<Path> for IconFile {
fn as_ref(&self) -> &Path {
self.path()
}
}
impl Borrow<Path> for IconFile {
fn borrow(&self) -> &Path {
self.path()
}
}