Struct password_gen::password_generator::PasswordGenerator
source · [−]pub struct PasswordGenerator { /* private fields */ }Expand description
Describes a password generator. Wrapper around a ThreadRng so it’s cached to improve performance when generating random characters. Dictionary also loaded when instantiated so it doesn’t have to be called multiple times.
Implementations
sourceimpl PasswordGenerator
impl PasswordGenerator
sourcepub fn new() -> PasswordGenerator
pub fn new() -> PasswordGenerator
Initialises a new PasswordGenerator, instantiating the ThreadRng and dictionary
Example
use password_gen::PasswordGenerator;
let generator = PasswordGenerator::new();sourceimpl PasswordGenerator
impl PasswordGenerator
sourcepub fn generate_password(&mut self, options: &PasswordOptions) -> String
pub fn generate_password(&mut self, options: &PasswordOptions) -> String
Generates a random password that match the given requirements.
Example
use password_gen::{PasswordOptions, PasswordGenerator};
use password_gen::password_options::CharSet;
let mut generator = PasswordGenerator::new();
let options = PasswordOptions::new(15, CharSet::Ascii);
let password = generator.generate_password(&options);Auto Trait Implementations
impl !RefUnwindSafe for PasswordGenerator
impl !Send for PasswordGenerator
impl !Sync for PasswordGenerator
impl Unpin for PasswordGenerator
impl !UnwindSafe for PasswordGenerator
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more