pub struct Filters {
pub alphanumeric: bool,
pub case_sensitive: bool,
pub min_length: i32,
pub max_length: i32,
pub punctuation: bool,
pub numbers: bool,
pub special_characters: bool,
pub accept_special_characters: Option<String>,
pub list_of_special_characters: Option<HashSet<char>>,
}
Expand description
A struct used to deserialize filters from the configuration file.
Fields§
§alphanumeric: bool
§case_sensitive: bool
§min_length: i32
§max_length: i32
§punctuation: bool
§numbers: bool
§special_characters: bool
§accept_special_characters: Option<String>
§list_of_special_characters: Option<HashSet<char>>
Implementations§
Source§impl Filters
impl Filters
pub fn set_special_characters(&mut self)
pub fn get_special_characters(&self) -> HashSet<char>
Sourcepub fn is_valid(&self, text: &str) -> bool
pub fn is_valid(&self, text: &str) -> bool
Checks if a string is a valid entity. Using the configuration file, it checks if the string is alphanumeric, contains punctuation, numbers, or special characters.
§Examples
use utils::is_valid;
let text = "Hello, world!";
assert_eq!(is_valid(config, text), true);
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Filters
impl<'de> Deserialize<'de> for Filters
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 Filters
impl RefUnwindSafe for Filters
impl Send for Filters
impl Sync for Filters
impl Unpin for Filters
impl UnwindSafe for Filters
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,
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