wallhaven_rs/models/enums/
resolution.rs1use std::fmt::Display;
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, Deserialize, Clone, Copy, Debug)]
11pub enum Resolution {
12 #[serde(rename = "1280x720")]
14 R1280x720,
15 #[serde(rename = "1280x800")]
17 R1280x800,
18 #[serde(rename = "1280x960")]
20 R1280x960,
21 #[serde(rename = "1280x1024")]
23 R1280x1024,
24 #[serde(rename = "3440x1440")]
26 R3440x1440,
27 #[serde(rename = "1600x900")]
29 R1600x900,
30 #[serde(rename = "1600x1000")]
32 R1600x1000,
33 #[serde(rename = "1600x1200")]
35 R1600x1200,
36 #[serde(rename = "1600x1280")]
38 R1600x1280,
39 #[serde(rename = "3840x1600")]
41 R3840x1600,
42 #[serde(rename = "1920x1080")]
44 R1920x1080,
45 #[serde(rename = "1920x1200")]
47 R1920x1200,
48 #[serde(rename = "1920x1440")]
50 R1920x1440,
51 #[serde(rename = "1920x1536")]
53 R1920x1536,
54 #[serde(rename = "2560x1080")]
56 R2560x1080,
57 #[serde(rename = "2560x1440")]
59 R2560x1440,
60 #[serde(rename = "2560x1600")]
62 R2560x1600,
63 #[serde(rename = "2560x1920")]
65 R2560x1920,
66 #[serde(rename = "2560x2048")]
68 R2560x2048,
69 #[serde(rename = "3840x2160")]
71 R3840x2160,
72 #[serde(rename = "3840x2400")]
74 R3840x2400,
75 #[serde(rename = "3840x2880")]
77 R3840x2880,
78 #[serde(rename = "3840x3072")]
80 R3840x3072,
81}
82
83impl Resolution {
84 #[must_use]
88 pub const fn dimensions(&self) -> (u32, u32) {
89 match self {
90 Self::R1280x720 => (1280, 720),
91 Self::R1280x800 => (1280, 800),
92 Self::R1280x960 => (1280, 960),
93 Self::R1600x900 => (1600, 900),
94 Self::R1280x1024 => (1280, 1024),
95 Self::R3440x1440 => (3440, 1440),
96 Self::R1600x1000 => (1600, 1000),
97 Self::R1600x1200 => (1600, 1200),
98 Self::R1600x1280 => (1600, 1280),
99 Self::R3840x1600 => (3840, 1600),
100 Self::R1920x1080 => (1920, 1080),
101 Self::R1920x1200 => (1920, 1200),
102 Self::R1920x1440 => (1920, 1440),
103 Self::R1920x1536 => (1920, 1536),
104 Self::R2560x1080 => (2560, 1080),
105 Self::R2560x1440 => (2560, 1440),
106 Self::R2560x1600 => (2560, 1600),
107 Self::R2560x1920 => (2560, 1920),
108 Self::R2560x2048 => (2560, 2048),
109 Self::R3840x2160 => (3840, 2160),
110 Self::R3840x2400 => (3840, 2400),
111 Self::R3840x2880 => (3840, 2880),
112 Self::R3840x3072 => (3840, 3072),
113 }
114 }
115}
116
117impl Display for Resolution {
118 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
119 let (w, h) = self.dimensions();
120 write!(f, "{w}x{h}")
121 }
122}