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
#[derive(Debug, Clone, PartialEq)]
pub struct Charset {
pub charset: String,
pub weight: f32,
}
impl Charset {
pub fn parse_string(charset: &str) -> Charset {
Charset {
charset: charset.to_string(),
weight: 1.0,
}
}
pub fn with_weight(&self, weight: &str) -> Charset {
Charset {
charset: self.charset.clone(),
weight: weight.parse().unwrap_or(1.0),
}
}
pub fn matches(&self, other: &Charset) -> bool {
other.charset == "*" || (self.charset.to_uppercase() == other.charset.to_uppercase())
}
pub fn to_string(&self) -> String {
self.charset.clone()
}
}