pub struct DisplayMask { /* private fields */ }Implementations§
Source§impl DisplayMask
impl DisplayMask
Sourcepub fn new(pattern: impl Into<String>, input_char: char) -> DisplayMask
pub fn new(pattern: impl Into<String>, input_char: char) -> DisplayMask
Create a new display mask with dynamic mode (current behavior)
§Arguments
pattern- The mask pattern (e.g., “##-##-####”, “(###) ###-####”)input_char- Character representing input positions (usually ‘#’)
§Examples
use validation_core::DisplayMask;
// Phone number format
let phone_mask = DisplayMask::new("(###) ###-####", '#');
// Date format
let date_mask = DisplayMask::new("##/##/####", '#');
// Custom business format
let employee_id = DisplayMask::new("EMP-####-##", '#');Sourcepub fn with_mode(self, mode: MaskDisplayMode) -> DisplayMask
pub fn with_mode(self, mode: MaskDisplayMode) -> DisplayMask
Set the display mode for this mask
§Examples
use validation_core::{DisplayMask, MaskDisplayMode};
let dynamic_mask = DisplayMask::new("##-##", '#')
.with_mode(MaskDisplayMode::Dynamic);
let template_mask = DisplayMask::new("##-##", '#')
.with_mode(MaskDisplayMode::Template { placeholder: '_' });Sourcepub fn with_template(self, placeholder: char) -> DisplayMask
pub fn with_template(self, placeholder: char) -> DisplayMask
Set template mode with custom placeholder
§Examples
use validation_core::DisplayMask;
let phone_template = DisplayMask::new("(###) ###-####", '#')
.with_template('_'); // Shows "(___) ___-____" when empty
let date_dots = DisplayMask::new("##/##/####", '#')
.with_template('•'); // Shows "••/••/••••" when emptySourcepub fn apply_to_display(&self, raw_input: &str) -> String
pub fn apply_to_display(&self, raw_input: &str) -> String
Apply mask to raw input, showing visual separators and handling display mode
Sourcepub fn is_input_position(&self, display_position: usize) -> bool
pub fn is_input_position(&self, display_position: usize) -> bool
Check if a display position should accept cursor/input
Sourcepub fn display_pos_to_raw_pos(&self, display_pos: usize) -> usize
pub fn display_pos_to_raw_pos(&self, display_pos: usize) -> usize
Map display position to raw position
Sourcepub fn raw_pos_to_display_pos(&self, raw_pos: usize) -> usize
pub fn raw_pos_to_display_pos(&self, raw_pos: usize) -> usize
Map raw position to display position
Sourcepub fn next_input_position(&self, display_pos: usize) -> usize
pub fn next_input_position(&self, display_pos: usize) -> usize
Find next input position at or after the given display position
Sourcepub fn prev_input_position(&self, display_pos: usize) -> Option<usize>
pub fn prev_input_position(&self, display_pos: usize) -> Option<usize>
Find previous input position at or before the given display position
Sourcepub fn display_mode(&self) -> &MaskDisplayMode
pub fn display_mode(&self) -> &MaskDisplayMode
Get the display mode
Sourcepub fn is_template_mode(&self) -> bool
pub fn is_template_mode(&self) -> bool
Check if this mask uses template mode
Sourcepub fn input_char(&self) -> char
pub fn input_char(&self) -> char
Get the input placeholder character
Sourcepub fn first_input_position(&self) -> usize
pub fn first_input_position(&self) -> usize
Get the position of the first input character in the pattern
Trait Implementations§
Source§impl Clone for DisplayMask
impl Clone for DisplayMask
Source§fn clone(&self) -> DisplayMask
fn clone(&self) -> DisplayMask
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DisplayMask
impl Debug for DisplayMask
Source§impl Default for DisplayMask
impl Default for DisplayMask
Source§fn default() -> DisplayMask
fn default() -> DisplayMask
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for DisplayMask
impl<'de> Deserialize<'de> for DisplayMask
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DisplayMask, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DisplayMask, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for DisplayMask
Source§impl PartialEq for DisplayMask
impl PartialEq for DisplayMask
Source§fn eq(&self, other: &DisplayMask) -> bool
fn eq(&self, other: &DisplayMask) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for DisplayMask
impl Serialize for DisplayMask
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for DisplayMask
Auto Trait Implementations§
impl Freeze for DisplayMask
impl RefUnwindSafe for DisplayMask
impl Send for DisplayMask
impl Sync for DisplayMask
impl Unpin for DisplayMask
impl UnsafeUnpin for DisplayMask
impl UnwindSafe for DisplayMask
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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