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

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());
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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

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)

Converts to this type from the input type.

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")

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

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)

Converts to this type from the input type.

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.