[][src]Struct mudders::SymbolTable

pub struct SymbolTable(_);

The functionality of the crate lives here.

A symbol table is, internally, a vector of valid ASCII bytes that are used to generate lexicographically evenly-spaced strings.

Methods

impl SymbolTable[src]

pub fn new(source: &[u8]) -> Result<Self, CreationError>[src]

Creates a new symbol table from the given byte slice. The slice is internally sorted using .sort().

An error is returned if one of the given bytes is out of ASCII range.

pub fn from_chars(source: &[char]) -> Result<Self, CreationError>[src]

Creates a new symbol table from the given characters. The slice is internally sorted using .sort().

An error is returned if one of the given characters is not ASCII.

pub fn alphabet() -> Self[src]

Returns a SymbolTable which contains the lowercase latin alphabet ([a-z]).

pub fn mudder(
    &self,
    a: &str,
    b: &str,
    amount: NonZeroUsize
) -> Result<Vec<String>, GenerationError>
[src]

Generate amount strings that lexicographically sort between start and end. The algorithm will try to make them as evenly-spaced as possible.

When both parameters are empty strings, amount new strings that are in lexicographical order are returned.

If parameter b is lexicographically before a, they are swapped internally.

// Using the included alphabet table
let table = SymbolTable::alphabet();
// Generate 10 strings from scratch
let results = table.mudder("", "", NonZeroUsize::new(10).unwrap()).unwrap();
assert!(results.len() == 10);
// results should look something like ["b", "d", "f", ..., "r", "t"]

pub fn mudder_one(&self, a: &str, b: &str) -> Result<String, GenerationError>[src]

Convenience wrapper around mudder to generate exactly one string.

Safety

This function calls NonZeroUsize::new_unchecked(1).

pub fn generate(
    &self,
    amount: NonZeroUsize
) -> Result<Vec<String>, GenerationError>
[src]

Convenience wrapper around mudder to generate an amount of fresh strings.

SymbolTable.generate(amount) is equivalent to SymbolTable.mudder("", "", amount).

Trait Implementations

impl Clone for SymbolTable[src]

impl Debug for SymbolTable[src]

impl FromStr for SymbolTable[src]

type Err = CreationError

The associated error which can be returned from parsing.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.