pub struct DictionarySubstringRule<D: Dictionary> { /* private fields */ }Expand description
Rule for determining if a password contains a dictionary word with optional checking for reversed words.
§Example
use passay_rs::dictionary::word_lists::word_list_dictionary::WordListDictionary;
use passay_rs::dictionary::word_lists::ArrayWordList;
use passay_rs::dictionary::word_lists::sort::SliceSort;
use passay_rs::rule::dictionary_substring::DictionarySubstringRule;
use passay_rs::rule::PasswordData;
use passay_rs::rule::Rule;
let words = ["test", "z", "x", "y", "man", "lance"].map(String::from).to_vec();
// world list should be sorted so we sort it now
let word_list = ArrayWordList::with_sorter(words, false, Some(SliceSort));
let dictionary = WordListDictionary::new(word_list);
let dictionary_rule = DictionarySubstringRule::new(dictionary, true);
let password = PasswordData::with_password("p4tlancely5gew".to_string());
let result = dictionary_rule.validate(&password);
assert!(!result.valid());Implementations§
Source§impl<D: Dictionary> DictionarySubstringRule<D>
impl<D: Dictionary> DictionarySubstringRule<D>
pub fn new(dictionary: D, match_backwards: bool) -> Self
pub fn from_dictionary(dictionary: D) -> Self
Trait Implementations§
Source§impl<D: Dictionary> DictionaryRuleTrait for DictionarySubstringRule<D>
impl<D: Dictionary> DictionaryRuleTrait for DictionarySubstringRule<D>
fn dictionary(&self) -> &dyn Dictionary
Source§impl<D: Dictionary> Rule for DictionarySubstringRule<D>
impl<D: Dictionary> Rule for DictionarySubstringRule<D>
fn validate(&self, password_data: &PasswordData) -> RuleResult
fn as_dictionary_rule(&self) -> Option<&dyn DictionaryRuleTrait>
fn as_has_characters(&self) -> Option<&dyn HasCharacters>
Auto Trait Implementations§
impl<D> Freeze for DictionarySubstringRule<D>where
D: Freeze,
impl<D> RefUnwindSafe for DictionarySubstringRule<D>where
D: RefUnwindSafe,
impl<D> Send for DictionarySubstringRule<D>where
D: Send,
impl<D> Sync for DictionarySubstringRule<D>where
D: Sync,
impl<D> Unpin for DictionarySubstringRule<D>where
D: Unpin,
impl<D> UnsafeUnpin for DictionarySubstringRule<D>where
D: UnsafeUnpin,
impl<D> UnwindSafe for DictionarySubstringRule<D>where
D: UnwindSafe,
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