[−][src]Struct mudders::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]
&self,
a: &str,
b: &str,
amount: NonZeroUsize
) -> Result<Vec<String>, GenerationError>
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]
&self,
amount: NonZeroUsize
) -> Result<Vec<String>, GenerationError>
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]
fn clone(&self) -> SymbolTable
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for SymbolTable
[src]
impl FromStr for SymbolTable
[src]
type Err = CreationError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, CreationError>
[src]
Auto Trait Implementations
impl RefUnwindSafe for SymbolTable
impl Send for SymbolTable
impl Sync for SymbolTable
impl Unpin for SymbolTable
impl UnwindSafe for SymbolTable
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,