1use std::fmt::Display;
2
3#[derive(Clone, Debug)]
4pub enum FaviconMimeType {
5 Ico,
7 Png,
9 Svg,
11 Gif,
13 Jpeg,
15 Webp
17}
18
19impl Display for FaviconMimeType {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 match self {
22 Self::Ico => write!(f, "image/x-icon"),
23 Self::Png => write!(f, "image/png"),
24 Self::Svg => write!(f, "image/svg+xml"),
25 Self::Gif => write!(f, "image/gif"),
26 Self::Jpeg => write!(f, "image/jpeg"),
27 Self::Webp => write!(f, "image/webp")
28 }
29 }
30}
31
32#[derive(Clone, Debug)]
36pub struct Favicon {
37 favicon: String,
38 mime: FaviconMimeType
39}
40
41impl Favicon {
42 pub fn new(favicon: String, mime: FaviconMimeType) -> Self {
43 Self { favicon, mime }
44 }
45
46 pub fn favicon(&self) -> &String {
47 &self.favicon
48 }
49
50 pub fn mime(&self) -> String {
51 self.mime.to_string()
52 }
53}
54
55impl Default for Favicon {
56 fn default() -> Self {
57 Self {
58 favicon: String::from("favicon.ico"),
59 mime: FaviconMimeType::Ico
60 }
61 }
62}