glory_render/
input_assist.rs1pub const MAX_INPUT_PLACEHOLDER_BYTES: usize = 4096;
3
4pub fn validate_input_placeholder(value: &str, multiline: bool) -> Result<(), crate::Error> {
6 if value.len() > MAX_INPUT_PLACEHOLDER_BYTES
7 || value.contains(['\0', '\r'])
8 || (!multiline && value.contains('\n'))
9 {
10 return Err(crate::Error::InvalidProps(
11 "invalid bounded input placeholder",
12 ));
13 }
14 Ok(())
15}
16#[derive(Clone, Copy, Debug, PartialEq, Eq)]
17pub enum InputAutofill {
18 Off,
19 OneTimeCode,
20}
21impl InputAutofill {
22 pub fn as_str(self) -> &'static str {
23 match self {
24 Self::Off => "off",
25 Self::OneTimeCode => "one-time-code",
26 }
27 }
28}
29#[derive(Clone, Copy, Debug, PartialEq, Eq)]
30pub enum InputMode {
31 Text,
32 Numeric,
33}
34impl InputMode {
35 pub fn as_str(self) -> &'static str {
36 match self {
37 Self::Text => "text",
38 Self::Numeric => "numeric",
39 }
40 }
41}
42#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
45pub struct InputAssist {
46 pub autofill: Option<InputAutofill>,
47 pub mode: Option<InputMode>,
48}