Struct osrand::RandomString
source · pub struct RandomString { /* private fields */ }
Expand description
A random string generator which gets it’s entropy from an internal
BufReader
wrapping the OS RNG device. This generator may be re-used
as many times as required.
Implementations§
source§impl RandomString
impl RandomString
sourcepub fn new(flags: &[Flags]) -> Result<Self, Error>
pub fn new(flags: &[Flags]) -> Result<Self, Error>
Creates a new random string generator, which gets it’s randomness
from an internal BufReader
around the OS RNG device. If flags
is empty, the full dictionary will be used.
§Errors
Returns an io error if there is a problem reading from the RNG device
sourcepub fn with_dict(dict: Vec<char>) -> Result<Self, Error>
pub fn with_dict(dict: Vec<char>) -> Result<Self, Error>
Creates a new random string generator with the given dictionary, which
gets it’s randomness from an internal BufReader
around the OS RNG device.
If dict
is empty, the full dictionary will be used.
§Errors
Returns an io error if there is a problem reading from the RNG device
sourcepub fn from_parts(rng: BufRng, dict: Vec<char>) -> Self
pub fn from_parts(rng: BufRng, dict: Vec<char>) -> Self
Creates a new random string generator from the provided BufRng
rngand the
Dictionary` dict.
§Errors
Returns an io error if there is a problem reading from the RNG device
sourcepub fn get_dictionary(&self) -> &[char]
pub fn get_dictionary(&self) -> &[char]
Gets the dictionary being used by the generator
sourcepub fn set_dictionary(&mut self, dict: Vec<char>)
pub fn set_dictionary(&mut self, dict: Vec<char>)
Sets the dictionary to be used for new random strings