pub struct PassConfig {
Show 16 fields pub capitalise: bool, pub replace: bool, pub randomise: bool, pub pass_amount: usize, pub reset_amount: usize, pub length: String, pub number_amount: String, pub special_chars_amount: String, pub special_chars: String, pub upper_amount: String, pub lower_amount: String, pub keep_numbers: bool, pub force_upper: bool, pub force_lower: bool, pub dont_upper: bool, pub dont_lower: bool, /* private fields */
}
Expand description

Used for configuring the password generator.

Fields

capitalise: bool
Uppercase the first character of every word

Makes the password much easier to read, but also slightly less secure due to the predictability of having capitalised words. Still, the highly improved readability makes it worth it to always have it on.

Default: false

replace: bool
Replace the original characters

Instead of inserting the numbers and special characters (which preserves the original letters), replace the characters at random positions.

Default: false

randomise: bool
Shuffle the words

Useful if the source text is just a list of words without order anyway and you want to have a different order with each run.

Default: false

pass_amount: usize
Amount of passwords to generate

Useful for providing a list of passwords to choose from.

Default: 1

reset_amount: usize
Amount of times to try generating password before truncating

If the range is too small or an exact number, it’ll be harder to get a fitting set of words, so the word selection will restart if the password exceeds the maximum length. But since it would keep looping if it doesn’t find the right length it needs a way to stop, which in this case is simply truncating the password to the maximum length.

Default: 10

length: String
Set the length of the password

Can either be a range like 24-30, which will generate a password between that length, or it can be an exact number like 25 for a password of that exact length.

Default: 24-30

number_amount: String
Amount of numbers to insert

Can take either a range like 2-4 or an exact amount like 2. Doesn’t take into consideration the amount of numbers already in the password if ‘keep-nums’ is activated.

Default: 1-2

special_chars_amount: String
Amount of special characters to insert

Can take either a range like 2-4 or an exact amount like 2.

Default: 1-2

special_chars: String
The special characters to insert

Non-ASCII characters are not supported and will error.

Default: ^!(-_=)$<[@.#]>%{~,+}&*

upper_amount: String
Amount of uppercase characters

Can take either a range like 2-4 or an exact amount like 2. If there are no uppercase characters, the force_upper flag is turned on automatically to capitalise up to the specified amount of alphabetic characters. But if there’s at least one uppercase character there won’t be any capitalisation unless force_upper is turned on manually.

Default: 1-2

lower_amount: String
Amount of lowercase characters

Can take either a range like 2-4 or an exact amount like 2. If there are no lowercase characters, the force_lower flag is turned on automatically to decapitalise up to the specified amount of alphabetic characters. But if there’s at least one lowercase character there won’t be any decapitalisation unless force_lower is turned on manually.

Default: 1-2

keep_numbers: bool
Choose to keep numbers from the source in the password

It will treat blocks of numbers as words, not counting them towards the amount of numbers to insert into the password.

Default: false

force_upper: bool
Force the specified amount of uppercase characters

Gets ignored if dont_upper is also set.

Default: false

force_lower: bool
Force the specified amount of lowercase characters

Gets ignored if dont_lower is also set.

Default: false

dont_upper: bool
Don’t uppercase at all to keep original casing

Ignores force_upper, both manual and automatic.

Default: false

dont_lower: bool
Don’t lowercase at all to keep original casing

Ignores force_lower, both manual and automatic.

Default: false

Implementations

Create a new configuration with default values.

Extract words from file or directory with text files.

In case of a directory, it recursively parses every file inside it while following links and ignoring non-plaintext files.

In case no words were extracted nothing is added and no error is given.

Accepts UTF-8 characters, but translates them to ASCII for use in the password. So if a word in another language is encountered, it will be transformed into a kind of phonetic spelling in ASCII, and if an emoji is encountered, it will be translated into its meaning, for example, :D would become ‘grinning’.

Errors:

This method will return an IO error in the following situations, but is not limited to just these cases:

  • path does not exist.
  • The user lacks permissions to perform metadata call on path.
  • The process lacks permissions to view the contents.

Extract words from a string.

In case no words were extracted nothing is added and no error is given.

Accepts UTF-8 characters, but translates them to ASCII for use in the password. So if a word in another language is encountered, it will be transformed into a kind of phonetic spelling in ASCII, and if an emoji is encountered, it will be translated into its meaning, for example, :D would become ‘grinning’.

Get a reference to the vector of words.

Check configuration for errors and get a validated configuration.

Errors:

Each error has a message, especially InvalidRange, which specifies the field the error came from. Read ValidationError for more information.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

A set of recommended settings for generating a password.

This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.