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§
Source§impl 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();
Source§impl 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 Freeze for PasswordGenerator
impl !RefUnwindSafe for PasswordGenerator
impl !Send for PasswordGenerator
impl !Sync for PasswordGenerator
impl Unpin for PasswordGenerator
impl !UnwindSafe for PasswordGenerator
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