pub struct CharacterLimits { /* private fields */ }Expand description
Character limits configuration for a field
Implementations§
Source§impl CharacterLimits
impl CharacterLimits
Sourcepub fn new_range(min_length: usize, max_length: usize) -> Self
pub fn new_range(min_length: usize, max_length: usize) -> Self
Create new character limits with min and max
Sourcepub fn new_warning(threshold: usize) -> Self
pub fn new_warning(threshold: usize) -> Self
Create new character limits with only a warning threshold.
Sourcepub fn with_warning_threshold(self, threshold: usize) -> Self
pub fn with_warning_threshold(self, threshold: usize) -> Self
Set warning threshold (when to show warning before hitting limit)
Sourcepub fn with_count_mode(self, mode: CountMode) -> Self
pub fn with_count_mode(self, mode: CountMode) -> Self
Set count mode (characters vs display width vs bytes)
Sourcepub fn max_length(&self) -> Option<usize>
pub fn max_length(&self) -> Option<usize>
Get maximum length
Sourcepub fn min_length(&self) -> Option<usize>
pub fn min_length(&self) -> Option<usize>
Get minimum length
Sourcepub fn warning_threshold(&self) -> Option<usize>
pub fn warning_threshold(&self) -> Option<usize>
Get warning threshold
Sourcepub fn count_mode(&self) -> CountMode
pub fn count_mode(&self) -> CountMode
Get count mode
Sourcepub fn validate_insertion(
&self,
current_text: &str,
position: usize,
character: char,
) -> Option<ValidationResult>
pub fn validate_insertion( &self, current_text: &str, position: usize, character: char, ) -> Option<ValidationResult>
Check if inserting a character would exceed limits
Sourcepub fn validate_content(&self, text: &str) -> Option<ValidationResult>
pub fn validate_content(&self, text: &str) -> Option<ValidationResult>
Validate the current content
Sourcepub fn check_limits(&self, text: &str) -> LimitCheckResult
pub fn check_limits(&self, text: &str) -> LimitCheckResult
Get the current status of the text against limits
Sourcepub fn status_text(&self, text: &str) -> Option<String>
pub fn status_text(&self, text: &str) -> Option<String>
Get a human-readable status string
pub fn allows_field_switch(&self, text: &str) -> bool
Sourcepub fn field_switch_block_reason(&self, text: &str) -> Option<String>
pub fn field_switch_block_reason(&self, text: &str) -> Option<String>
Get reason why field switching is not allowed (if any)
Trait Implementations§
Source§impl Clone for CharacterLimits
impl Clone for CharacterLimits
Source§fn clone(&self) -> CharacterLimits
fn clone(&self) -> CharacterLimits
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 CharacterLimits
impl Debug for CharacterLimits
Source§impl Default for CharacterLimits
impl Default for CharacterLimits
Source§impl<'de> Deserialize<'de> for CharacterLimits
impl<'de> Deserialize<'de> for CharacterLimits
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CharacterLimits
impl RefUnwindSafe for CharacterLimits
impl Send for CharacterLimits
impl Sync for CharacterLimits
impl Unpin for CharacterLimits
impl UnsafeUnpin for CharacterLimits
impl UnwindSafe for CharacterLimits
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