pub struct InputMask { /* private fields */ }Expand description
Parsed mask: a sequence of positions, ready for rendering and per-character routing.
Implementations§
Source§impl InputMask
impl InputMask
Sourcepub fn parse(mask: &str) -> Result<Self, MaskError>
pub fn parse(mask: &str) -> Result<Self, MaskError>
Parse a Qt-grammar mask string. Errors only on a trailing backslash with nothing to escape; any unrecognized printable char becomes a fixed literal. (Qt is similarly permissive.)
Sourcepub fn positions(&self) -> impl Iterator<Item = &MaskPosition>
pub fn positions(&self) -> impl Iterator<Item = &MaskPosition>
Iterator over positions in document order.
Sourcepub fn get(&self, i: usize) -> Option<&MaskPosition>
pub fn get(&self, i: usize) -> Option<&MaskPosition>
Position at index i, or None if out of bounds.
Sourcepub fn empty_template(&self, placeholder_char: char) -> String
pub fn empty_template(&self, placeholder_char: char) -> String
Render the mask as the empty-state template: every editable
position becomes placeholder_char, every fixed position keeps
its literal. So 99/99/9999 with _ → "__/__/____".
Sourcepub fn format(&self, raw: &str, placeholder_char: char) -> FormattedMask
pub fn format(&self, raw: &str, placeholder_char: char) -> FormattedMask
Apply the mask to raw input. Walks raw and the mask in
lockstep:
- At a fixed-separator position, the separator is appended
automatically (the user doesn’t need to type it). If the next
rawchar matches the separator it’s consumed; otherwise it stays for the next editable position. - At an editable position, the next
rawchar is consumed if it fits the class, else dropped. - Case lock is applied to letter/alphanumeric/any chars.
- When
rawis exhausted, the rest of the formatted string usesplaceholder_charfor editable positions and the literal for fixed ones — giving a partial template like"12/__/____".
The result is the fully-templated string (with placeholder characters for unfilled positions), suitable for direct rendering. To get just the user’s input keep raw and don’t call this; to get a string with separators but no placeholders, truncate at the position past the last filled editable slot.
Sourcepub fn strip_trailing_placeholders(&self, formatted: &FormattedMask) -> String
pub fn strip_trailing_placeholders(&self, formatted: &FormattedMask) -> String
Strip placeholder characters from the tail of a formatted
string. Returns the prefix containing only filled positions
and their preceding separators. "12/__/____" → "12/",
"12/30/____" → "12/30/", "____" → "".
Sourcepub fn accepts_at(&self, pos_index: usize, c: char) -> bool
pub fn accepts_at(&self, pos_index: usize, c: char) -> bool
Position-aware char filter: returns true iff c would be
accepted at editable position pos_index. Fixed positions
never accept input directly (the caret should skip over them).
Out-of-range indices reject. Used by composites that want to
gate keystrokes per-position.
Trait Implementations§
impl Eq for InputMask
impl StructuralPartialEq for InputMask
Auto Trait Implementations§
impl Freeze for InputMask
impl RefUnwindSafe for InputMask
impl Send for InputMask
impl Sync for InputMask
impl Unpin for InputMask
impl UnsafeUnpin for InputMask
impl UnwindSafe for InputMask
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more