FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    MaskedTextProvider

    struct · ferroui-controls · v0.5.0

    struct MaskedTextProvider
    

    Provides functionality for formatting a test string against a mask string. MaskedTextProvider::add, MaskedTextProvider::insert_at, MaskedTextProvider::remove_at and the like modify the state of the test string; Clone produces an independent copy with the same state.

    View source

    Members

    INVALID_INDEX

    const INVALID_INDEX: i32
    

    The index returned by the find_* methods when nothing is found (-1).

    Source

    DEFAULT_PASSWORD_CHAR

    const DEFAULT_PASSWORD_CHAR: char
    

    The password character used by Self::set_is_password (*).

    Source

    new

    fn new(mask: &str) -> Result<Self, MaskedTextProviderError>
    

    Creates a provider for mask with the current culture, the prompt allowed as input, _ as prompt, no password character and no ASCII restriction.

    Source

    new_with_ascii

    fn new_with_ascii(mask: &str, restrict_to_ascii: bool) -> Result<Self, MaskedTextProviderError>
    

    Creates a provider for mask, optionally restricted to ASCII input.

    Source

    new_with_culture

    fn new_with_culture(mask: &str, culture: Option<CultureInfo>) -> Result<Self, MaskedTextProviderError>
    

    Creates a provider for mask with a culture.

    Source

    new_with_culture_ascii

    fn new_with_culture_ascii(mask: &str, culture: Option<CultureInfo>, restrict_to_ascii: bool) -> Result<Self, MaskedTextProviderError>
    

    Creates a provider for mask with a culture, optionally restricted to ASCII input.

    Source

    new_with_password

    fn new_with_password(mask: &str, password_char: char, allow_prompt_as_input: bool) -> Result<Self, MaskedTextProviderError>
    

    Creates a provider for mask with a password character ('\0' for none).

    Source

    new_with_culture_password

    fn new_with_culture_password(mask: &str, culture: Option<CultureInfo>, password_char: char, allow_prompt_as_input: bool) -> Result<Self, MaskedTextProviderError>
    

    Creates a provider for mask with a culture and a password character ('\0' for none).

    Source

    new_full

    fn new_full(mask: &str, culture: Option<CultureInfo>, allow_prompt_as_input: bool, prompt_char: char, password_char: char, restrict_to_ascii: bool) -> Result<Self, MaskedTextProviderError>
    

    Creates a provider.

    • mask — the mask; must not be empty and must only contain valid mask characters (Self::is_valid_mask_char).
    • culture — the culture providing the separators; None is the current culture.
    • allow_prompt_as_input — whether the prompt character is accepted as input.
    • prompt_char — the character shown at unassigned edit positions.
    • password_char — the character shown instead of the input, '\0' for none.
    • restrict_to_ascii — whether letters and characters are restricted to ASCII.

    As in the original, the prompt and password characters are not validated here (only their setters validate).

    Source

    allow_prompt_as_input

    fn allow_prompt_as_input(self: &Self) -> bool
    

    Whether the prompt character is accepted as valid input.

    Source

    assigned_edit_position_count

    fn assigned_edit_position_count(self: &Self) -> i32
    

    The number of edit positions that have a character assigned.

    Source

    available_edit_position_count

    fn available_edit_position_count(self: &Self) -> i32
    

    The number of edit positions that have no character assigned.

    Source

    culture

    fn culture(self: &Self) -> &CultureInfo
    

    The culture that provides the separators.

    Source

    default_password_char

    fn default_password_char() -> char
    

    The default password character (*).

    Source

    edit_position_count

    fn edit_position_count(self: &Self) -> i32
    

    The number of edit positions in the test string.

    Source

    edit_positions

    fn edit_positions(self: &Self) -> impl Iterator<Item = i32> + '_
    

    The edit positions of the test string, in ascending order.

    Source

    include_literals

    fn include_literals(self: &Self) -> bool
    

    Whether literals are included in the formatted string (fmt::Display and the to_string_* methods without an explicit flag). Default true.

    Source

    set_include_literals

    fn set_include_literals(self: &mut Self, value: bool)
    

    Sets Self::include_literals.

    Source

    include_prompt

    fn include_prompt(self: &Self) -> bool
    

    Whether prompt characters are included in the formatted string. Default false.

    Source

    set_include_prompt

    fn set_include_prompt(self: &mut Self, value: bool)
    

    Sets Self::include_prompt.

    Source

    ascii_only

    fn ascii_only(self: &Self) -> bool
    

    Whether only ASCII characters are valid input for the letter, alphanumeric and "any character" mask elements.

    Source

    is_password

    fn is_password(self: &Self) -> bool
    

    Whether the input is displayed with a password character.

    Source

    set_is_password

    fn set_is_password(self: &mut Self, value: bool)
    

    Turns the password display on (with Self::DEFAULT_PASSWORD_CHAR) or off; does nothing when it already is in the requested state.

    Source

    invalid_index

    fn invalid_index() -> i32
    

    The index returned by the find_* methods when nothing is found (-1).

    Source

    last_assigned_position

    fn last_assigned_position(self: &Self) -> i32
    

    The position of the last assigned edit position, or Self::INVALID_INDEX.

    Source

    length

    fn length(self: &Self) -> i32
    

    The length of the test string (the mask without modifiers and with the separators replaced by the culture's).

    Source

    mask

    fn mask(self: &Self) -> &str
    

    The mask.

    Source

    mask_completed

    fn mask_completed(self: &Self) -> bool
    

    Whether all required edit positions have been assigned.

    Source

    mask_full

    fn mask_full(self: &Self) -> bool
    

    Whether all edit positions (required and optional) have been assigned.

    Source

    password_char

    fn password_char(self: &Self) -> char
    

    The character displayed instead of the input, '\0' for none.

    Source

    set_password_char

    fn set_password_char(self: &mut Self, value: char) -> Result<(), MaskedTextProviderError>
    

    Sets the password character ('\0' for none). It must differ from the prompt character and be a valid password character.

    Source

    prompt_char

    fn prompt_char(self: &Self) -> char
    

    The character displayed at unassigned edit positions.

    Source

    set_prompt_char

    fn set_prompt_char(self: &mut Self, value: char) -> Result<(), MaskedTextProviderError>
    

    Sets the prompt character. It must differ from the password character and be a valid input character. The unassigned edit positions of the test string are updated.

    Source

    reset_on_prompt

    fn reset_on_prompt(self: &Self) -> bool
    

    Whether a prompt character in the input resets the position it lands on instead of being tested against the mask. Default true.

    Source

    set_reset_on_prompt

    fn set_reset_on_prompt(self: &mut Self, value: bool)
    

    Sets Self::reset_on_prompt.

    Source

    reset_on_space

    fn reset_on_space(self: &Self) -> bool
    

    Whether a space in the input resets the position it lands on instead of being tested against the mask. Default true.

    Source

    set_reset_on_space

    fn set_reset_on_space(self: &mut Self, value: bool)
    

    Sets Self::reset_on_space.

    Source

    skip_literals

    fn skip_literals(self: &Self) -> bool
    

    Whether an input character equal to the literal at its position is accepted and skipped. Default true.

    Source

    set_skip_literals

    fn set_skip_literals(self: &mut Self, value: bool)
    

    Sets Self::skip_literals.

    Source

    char_at

    fn char_at(self: &Self, index: i32) -> char
    

    The character of the test string at index.

    Panics

    Panics when index is out of range.

    Source

    add_char

    fn add_char(self: &mut Self, input: char) -> bool
    

    Attempts to add input at the first edit position after the last assigned one.

    Source

    add_char_with_hint

    fn add_char_with_hint(self: &mut Self, input: char) -> (bool, i32, MaskedTextResultHint)
    

    As Self::add_char; also returns the position the character was tested at (the length of the test string when there is none) and the result hint.

    Source

    add

    fn add(self: &mut Self, input: &str) -> bool
    

    Attempts to add the characters of input after the last assigned position. All of them are added, or none.

    Source

    add_with_hint

    fn add_with_hint(self: &mut Self, input: &str) -> (bool, i32, MaskedTextResultHint)
    

    As Self::add; also returns the position of the last character tested (on failure: the failing position) and the result hint.

    Source

    clear

    fn clear(self: &mut Self)
    

    Resets all edit positions.

    Source

    clear_with_hint

    fn clear_with_hint(self: &mut Self) -> MaskedTextResultHint
    

    As Self::clear; returns MaskedTextResultHint::NoEffect when nothing was assigned, MaskedTextResultHint::Success otherwise.

    Source

    find_assigned_edit_position_from

    fn find_assigned_edit_position_from(self: &Self, position: i32, direction: bool) -> i32
    

    The first assigned edit position from position in the direction (true forward, false backward), or Self::INVALID_INDEX.

    Source

    find_assigned_edit_position_in_range

    fn find_assigned_edit_position_in_range(self: &Self, start_position: i32, end_position: i32, direction: bool) -> i32
    

    The first assigned edit position in the inclusive range, searching in the direction, or Self::INVALID_INDEX.

    Source

    find_edit_position_from

    fn find_edit_position_from(self: &Self, position: i32, direction: bool) -> i32
    

    The first edit position (assigned or not) from position in the direction, or Self::INVALID_INDEX.

    Source

    find_edit_position_in_range

    fn find_edit_position_in_range(self: &Self, start_position: i32, end_position: i32, direction: bool) -> i32
    

    The first edit position (assigned or not) in the inclusive range, searching in the direction, or Self::INVALID_INDEX.

    Source

    find_non_edit_position_from

    fn find_non_edit_position_from(self: &Self, position: i32, direction: bool) -> i32
    

    The first non-edit position (literal or separator) from position in the direction, or Self::INVALID_INDEX.

    Source

    find_non_edit_position_in_range

    fn find_non_edit_position_in_range(self: &Self, start_position: i32, end_position: i32, direction: bool) -> i32
    

    The first non-edit position in the inclusive range, searching in the direction, or Self::INVALID_INDEX.

    Source

    find_unassigned_edit_position_from

    fn find_unassigned_edit_position_from(self: &Self, position: i32, direction: bool) -> i32
    

    The first unassigned edit position from position in the direction, or Self::INVALID_INDEX.

    Source

    find_unassigned_edit_position_in_range

    fn find_unassigned_edit_position_in_range(self: &Self, start_position: i32, end_position: i32, direction: bool) -> i32
    

    The first unassigned edit position in the inclusive range, searching in the direction, or Self::INVALID_INDEX.

    Source

    get_operation_result_from_hint

    fn get_operation_result_from_hint(hint: MaskedTextResultHint) -> bool
    

    Whether a hint describes a success (positive) or a failure.

    Source

    insert_at_char

    fn insert_at_char(self: &mut Self, input: char, position: i32) -> bool
    

    Attempts to insert input at position (or the first edit position after it), shifting the existing characters right.

    Source

    insert_at_char_with_hint

    fn insert_at_char_with_hint(self: &mut Self, input: char, position: i32) -> (bool, i32, MaskedTextResultHint)
    

    As Self::insert_at_char; also returns the position of the inserted character (on failure: the failing position) and the result hint.

    Source

    insert_at

    fn insert_at(self: &mut Self, input: &str, position: i32) -> bool
    

    Attempts to insert the characters of input from position, shifting the existing characters right. All of them are inserted, or none.

    Source

    insert_at_with_hint

    fn insert_at_with_hint(self: &mut Self, input: &str, position: i32) -> (bool, i32, MaskedTextResultHint)
    

    As Self::insert_at; also returns the position of the last inserted character (on failure: the failing position) and the result hint.

    Source

    is_available_position

    fn is_available_position(self: &Self, position: i32) -> bool
    

    Whether position is an edit position with no character assigned.

    Source

    is_edit_position

    fn is_edit_position(self: &Self, position: i32) -> bool
    

    Whether position is an edit position.

    Source

    is_valid_input_char

    fn is_valid_input_char(c: char) -> bool
    

    Whether c is a valid input character: a letter, digit, punctuation, symbol or the space.

    Source

    is_valid_mask_char

    fn is_valid_mask_char(c: char) -> bool
    

    Whether c is a valid mask character (the same set as Self::is_valid_input_char).

    Source

    is_valid_password_char

    fn is_valid_password_char(c: char) -> bool
    

    Whether c is a valid password character: a valid input character, or '\0' (no password character).

    Source

    remove

    fn remove(self: &mut Self) -> bool
    

    Removes the last assigned character. Always succeeds.

    Source

    remove_with_hint

    fn remove_with_hint(self: &mut Self) -> (bool, i32, MaskedTextResultHint)
    

    As Self::remove; also returns the position of the removed character (0 when there was none) and the result hint.

    Source

    remove_at

    fn remove_at(self: &mut Self, position: i32) -> bool
    

    Removes the character at position, shifting the characters after it left.

    Source

    remove_at_range

    fn remove_at_range(self: &mut Self, start_position: i32, end_position: i32) -> bool
    

    Removes the characters in the inclusive range, shifting the characters after it left.

    Source

    remove_at_range_with_hint

    fn remove_at_range_with_hint(self: &mut Self, start_position: i32, end_position: i32) -> (bool, i32, MaskedTextResultHint)
    

    As Self::remove_at_range; also returns the position the operation was performed at (on failure: the failing position) and the result hint.

    Source

    replace_char

    fn replace_char(self: &mut Self, input: char, position: i32) -> bool
    

    Replaces the character at position (or the first edit position after it) with input.

    Source

    replace_char_with_hint

    fn replace_char_with_hint(self: &mut Self, input: char, position: i32) -> (bool, i32, MaskedTextResultHint)
    

    As Self::replace_char; also returns the position of the replaced character (on failure: the failing position) and the result hint.

    Source

    replace_char_range_with_hint

    fn replace_char_range_with_hint(self: &mut Self, input: char, start_position: i32, end_position: i32) -> (bool, i32, MaskedTextResultHint)
    

    Replaces the characters in the inclusive range with input, removing the rest of the range and shifting the characters after it left.

    Source

    replace

    fn replace(self: &mut Self, input: &str, position: i32) -> bool
    

    Replaces the characters from position with the characters of input, without shifting. An empty input removes the character at position.

    Source

    replace_with_hint

    fn replace_with_hint(self: &mut Self, input: &str, position: i32) -> (bool, i32, MaskedTextResultHint)
    

    As Self::replace; also returns the position of the last replaced character (on failure: the failing position) and the result hint.

    Source

    replace_range_with_hint

    fn replace_range_with_hint(self: &mut Self, input: &str, start_position: i32, end_position: i32) -> (bool, i32, MaskedTextResultHint)
    

    Replaces the characters in the inclusive range with the characters of input: when the input is shorter than the range the rest of the range is removed, when it is longer the characters after the range shift right. An empty input removes the range.

    Source

    set

    fn set(self: &mut Self, input: &str) -> bool
    

    Sets the test string to input: the previous content is replaced. Nothing changes when the input does not fit the mask.

    Source

    set_with_hint

    fn set_with_hint(self: &mut Self, input: &str) -> (bool, i32, MaskedTextResultHint)
    

    As Self::set; also returns the position of the last character set (on failure: the failing position) and the result hint.

    Source

    to_display_string

    fn to_display_string(self: &Self) -> String
    

    The formatted string as it is to be displayed: prompts and literals included, and the input replaced by the password character if there is one.

    Source

    to_string_ignore_password

    fn to_string_ignore_password(self: &Self, ignore_password_char: bool) -> String
    

    The formatted string, with prompts and literals according to Self::include_prompt and Self::include_literals; the password character is used unless ignore_password_char.

    Source

    to_string_range

    fn to_string_range(self: &Self, start_position: i32, length: i32) -> String
    

    A part of the formatted string, with prompts and literals according to Self::include_prompt and Self::include_literals, ignoring the password character.

    Source

    to_string_ignore_password_range

    fn to_string_ignore_password_range(self: &Self, ignore_password_char: bool, start_position: i32, length: i32) -> String
    

    A part of the formatted string, with prompts and literals according to Self::include_prompt and Self::include_literals; the password character is used unless ignore_password_char.

    Source

    to_string_include

    fn to_string_include(self: &Self, include_prompt: bool, include_literals: bool) -> String
    

    The formatted string with or without prompts and literals, ignoring the password character.

    Source

    to_string_include_range

    fn to_string_include_range(self: &Self, include_prompt: bool, include_literals: bool, start_position: i32, length: i32) -> String
    

    A part of the formatted string with or without prompts and literals, ignoring the password character.

    Source

    to_string_with

    fn to_string_with(self: &Self, ignore_password_char: bool, include_prompt: bool, include_literals: bool, start_position: i32, length: i32) -> String
    

    A part of the formatted string.

    • ignore_password_char — show the input even when there is a password character.
    • include_prompt — keep the prompt at unassigned positions; without it they become spaces, and the string ends at the last assigned position (or the last literal, when literals are included).
    • include_literals — keep the literals and separators.
    • start_position, length — the part of the test string; clamped to it.

    Source

    verify_char

    fn verify_char(self: &Self, input: char, position: i32) -> (bool, MaskedTextResultHint)
    

    Tests whether input would be accepted at position, without changing anything. Returns the result and its hint.

    Source

    verify_escape_char

    fn verify_escape_char(self: &Self, input: char, position: i32) -> bool
    

    Tests whether input would be escaped at position: skipped as a matching literal, or taken as a reset (prompt or space).

    Source

    verify_string

    fn verify_string(self: &Self, input: &str) -> bool
    

    Tests whether input could be set (Self::set), without changing anything.

    Source

    verify_string_with_hint

    fn verify_string_with_hint(self: &Self, input: &str) -> (bool, i32, MaskedTextResultHint)
    

    As Self::verify_string; also returns the position of the last character tested (on failure: the failing position) and the result hint.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • ClassDefaults
    • ErasedDestructor
    • IntoEither
    • Clone
    • Debug
    • Display
    • Index<i32>

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.