pub struct RandomBlock { /* private fields */ }
Expand description
Builder for generating random strings or bytes.
§Generation.
There are 2 (actually 3) types of byte generation. The underneath concept is to generate random bytes for both UTF8 strings and bytes or byte sequences. This generator breaks up the sequence of characters or bytes and from the sequence of combinations it will generate a series of random bytes. if the sequence of bytes are generated from a valid UTF8 string, then each letter can be seperated and used for generating a random sequence of the valid sequences of bytes. This allows for the byte -> UTF8 convertion to be almost infallible.
This also means that if the system is supplied with a set of words the generator can randomly put those words together into a sequence.
use randomizer::Randomizer;
let string = Randomizer::ALPHABETICAL(6).string().unwrap();
assert_eq!(string.chars().count(), 6 );
Implementations§
Source§impl RandomBlock
§Public RandomBlock Implementation
impl RandomBlock
§Public RandomBlock Implementation
Sourcepub fn inner(&self) -> &Vec<u8> ⓘ
pub fn inner(&self) -> &Vec<u8> ⓘ
§Inner reference
Getting the [‘RandomBlock’] inner data as a reference.
use randomizer::RandomBlock;
let random_block = RandomBlock::default();
assert_eq!(random_block.inner(), &Vec::new());
Sourcepub fn inner_mut(&mut self) -> &mut Vec<u8> ⓘ
pub fn inner_mut(&mut self) -> &mut Vec<u8> ⓘ
§Inner mutable reference
Getting the [‘RandomBlock’] inner data as a mutable reference.
use randomizer::RandomBlock;
let mut random_block = RandomBlock::default();
*random_block.inner_mut() = vec![100u8, 100u8, 100u8];
assert_eq!(random_block.inner(), &vec![100u8, 100u8, 100u8]);
Trait Implementations§
Source§impl Clone for RandomBlock
impl Clone for RandomBlock
Source§fn clone(&self) -> RandomBlock
fn clone(&self) -> RandomBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for RandomBlock
impl Debug for RandomBlock
Source§impl Default for RandomBlock
impl Default for RandomBlock
Source§fn default() -> RandomBlock
fn default() -> RandomBlock
Source§impl From<&Vec<u8>> for RandomBlock
§Convert &Vec to RandomBlock
use randomizer::RandomBlock;
let foo_vec = vec![100u8, 100u8, 100u8];
let random_block: RandomBlock = RandomBlock::from(&foo_vec);
assert_eq!(random_block.inner(), &foo_vec)
impl From<&Vec<u8>> for RandomBlock
§Convert &Vec to RandomBlock
use randomizer::RandomBlock;
let foo_vec = vec![100u8, 100u8, 100u8];
let random_block: RandomBlock = RandomBlock::from(&foo_vec);
assert_eq!(random_block.inner(), &foo_vec)
Source§impl From<RandomBlock> for Result<String, Error>
§Convert RandomBlock into String
since its not possible to convert RandomBlock into a string by default this will convert the
RandomBlock into a [‘Result<String, Error>’].
impl From<RandomBlock> for Result<String, Error>
§Convert RandomBlock into String
since its not possible to convert RandomBlock into a string by default this will convert the RandomBlock into a [‘Result<String, Error>’].
use randomizer::{RandomBlock,Error};
let foo_vec = vec![100u8, 100u8, 100u8];
let random_block: RandomBlock = RandomBlock::from(&foo_vec);
let string_res: Result<String, Error> = random_block.into();
assert_eq!(string_res.unwrap(), "ddd")