Struct randomizer::RandomBlock
source · [−]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
sourceimpl RandomBlock
impl RandomBlock
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
sourceimpl Clone for RandomBlock
impl Clone for RandomBlock
sourcefn clone(&self) -> RandomBlock
fn clone(&self) -> RandomBlock
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for RandomBlock
impl Debug for RandomBlock
sourceimpl Default for RandomBlock
impl Default for RandomBlock
sourcefn default() -> RandomBlock
fn default() -> RandomBlock
Returns the “default value” for a type. Read more
sourceimpl From<&Vec<u8, Global>> for RandomBlock
impl From<&Vec<u8, Global>> 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)
sourceimpl From<RandomBlock> for 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")
sourceimpl From<RandomBlock> for Result<Vec<u8>, Error>
impl From<RandomBlock> for Result<Vec<u8>, Error>
sourcefn from(r: RandomBlock) -> Self
fn from(r: RandomBlock) -> Self
Converts to this type from the input type.
sourceimpl From<RandomBlock> for Vec<u8>
impl From<RandomBlock> for Vec<u8>
sourcefn from(r: RandomBlock) -> Self
fn from(r: RandomBlock) -> Self
Converts to this type from the input type.
sourceimpl From<Vec<u8, Global>> for RandomBlock
impl From<Vec<u8, Global>> for RandomBlock
Convert Vec to RandomBlock
use randomizer::RandomBlock;
let foo_vec = vec![100u8, 100u8, 100u8];
let random_block: RandomBlock = foo_vec.clone().into();
assert_eq!(random_block.inner(), &foo_vec)
Auto Trait Implementations
impl RefUnwindSafe for RandomBlock
impl Send for RandomBlock
impl Sync for RandomBlock
impl Unpin for RandomBlock
impl UnwindSafe for RandomBlock
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