webrtc_constraints/
enumerations.rs1#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
6pub enum FacingMode {
7    User,
9
10    Environment,
12
13    Left,
15
16    Right,
18}
19
20impl FacingMode {
21    pub fn user() -> String {
23        Self::User.to_string()
24    }
25
26    pub fn environment() -> String {
28        Self::Environment.to_string()
29    }
30
31    pub fn left() -> String {
33        Self::Left.to_string()
34    }
35
36    pub fn right() -> String {
38        Self::Right.to_string()
39    }
40}
41
42impl std::fmt::Display for FacingMode {
43    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44        match self {
45            Self::User => f.write_str("user"),
46            Self::Environment => f.write_str("environment"),
47            Self::Left => f.write_str("left"),
48            Self::Right => f.write_str("right"),
49        }
50    }
51}
52
53#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
58pub enum ResizeMode {
59    None,
68
69    CropAndScale,
75}
76
77impl ResizeMode {
78    pub fn none() -> String {
80        Self::None.to_string()
81    }
82
83    pub fn crop_and_scale() -> String {
85        Self::CropAndScale.to_string()
86    }
87}
88
89impl std::fmt::Display for ResizeMode {
90    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
91        match self {
92            Self::None => f.write_str("none"),
93            Self::CropAndScale => f.write_str("crop-and-scale"),
94        }
95    }
96}
97
98#[cfg(test)]
99mod tests {
100    use super::*;
101
102    mod facing_mode {
103        use super::*;
104
105        #[test]
106        fn to_string() {
107            assert_eq!(FacingMode::User.to_string(), "user");
108            assert_eq!(FacingMode::Environment.to_string(), "environment");
109            assert_eq!(FacingMode::Left.to_string(), "left");
110            assert_eq!(FacingMode::Right.to_string(), "right");
111
112            assert_eq!(FacingMode::user(), "user");
113            assert_eq!(FacingMode::environment(), "environment");
114            assert_eq!(FacingMode::left(), "left");
115            assert_eq!(FacingMode::right(), "right");
116        }
117    }
118
119    mod resize_mode {
120        use super::*;
121
122        #[test]
123        fn to_string() {
124            assert_eq!(ResizeMode::None.to_string(), "none");
125            assert_eq!(ResizeMode::CropAndScale.to_string(), "crop-and-scale");
126
127            assert_eq!(ResizeMode::none(), "none");
128            assert_eq!(ResizeMode::crop_and_scale(), "crop-and-scale");
129        }
130    }
131}