glory_render/
typeahead.rs1use crate::Error;
4
5pub const MAX_TYPEAHEAD_MILLIS: u64 = 9_007_199_254_740_991;
6
7pub fn validate_typeahead(text: &str, at_millis: u64) -> Result<(), Error> {
8 let mut chars = text.chars();
9 if at_millis > MAX_TYPEAHEAD_MILLIS
10 || !chars
11 .next()
12 .is_some_and(|character| !character.is_control() && !character.is_whitespace())
13 || chars.next().is_some()
14 {
15 return Err(Error::InvalidEvent(
16 "typeahead requires one printable nonspace scalar and a finite clock",
17 ));
18 }
19 Ok(())
20}