Skip to main content

entrust_dialog/input/
mask.rs

1#[derive(Clone, Copy, Debug)]
2pub struct InputMask {
3    pub(super) char: char,
4    pub(super) active: bool,
5}
6
7impl InputMask {
8    pub fn dots() -> Self {
9        '•'.into()
10    }
11
12    pub fn whitespace() -> Self {
13        ' '.into()
14    }
15
16    pub fn none() -> Self {
17        Self {
18            char: ' ',
19            active: false,
20        }
21    }
22
23    pub(super) fn toggle(&mut self) {
24        self.active = !self.active;
25    }
26}
27
28impl From<char> for InputMask {
29    fn from(value: char) -> Self {
30        InputMask {
31            char: value,
32            active: true,
33        }
34    }
35}
36
37impl Default for InputMask {
38    fn default() -> Self {
39        Self::none()
40    }
41}