Skip to main content

Pattern

Enum Pattern 

Source
pub enum Pattern<S: State = Parsed> {
    Group(Group<S>),
    Set(Set<S>),
    Special(Special<S>),
    Literal(Literal<S>),
}
Expand description

A pattern, or a part of one.

Variants§

§

Group(Group<S>)

One of several segments, as in (a|b).

§

Set(Set<S>)

One character out of a set, as in [a-z].

§

Special(Special<S>)

A word from a wordlist or a Markov chain, or a preset.

§

Literal(Literal<S>)

Characters that are output as they are.

Implementations§

Source§

impl Pattern<Prepared>

Source

pub fn generate(&self, rng: &mut dyn RandomStream) -> Result<String, Error>

Generates a passphrase.

Source

pub fn generate_with_entropy( &self, rng: &mut dyn RandomStream, ) -> Result<(String, Entropy), Error>

Generates a passphrase, and measures the entropy of the choices that were made for it.

Source

pub fn generate_into( &self, rng: &mut dyn RandomStream, output: &mut dyn Write, ) -> Result<Entropy, Error>

Generates a passphrase and writes it to the output. Returns the entropy of the choices that were made for it.

Source

pub fn generate_limited( &self, rng: &mut dyn RandomStream, output: &mut dyn Write, steps: usize, ) -> Result<Entropy, Error>

Generates a passphrase and writes it to the output, in no more than a number of steps (see STEP_LIMIT, which is what the other methods use). Returns the entropy of the choices that were made for it.

When it would take more steps, this fails. What was generated up to then has been written to the output.

Source§

impl Pattern<Parsed>

Source

pub fn optimize(self) -> (Pattern<Optimized>, Dependencies)

Optimizes the pattern, which does not change what it generates. Also returns what the pattern needs to be there when it is prepared.

Source§

impl Pattern<Parsed>

Source

pub fn parse(input: &str) -> Result<Self, Error>

Parses a pattern.

Source§

impl Pattern<Optimized>

Source

pub fn prepare(self, data: &dyn Data) -> Result<Pattern<Prepared>, Error>

Prepares the pattern for generation, with the wordlists, Markov chains and presets that it uses taken from the data.

Trait Implementations§

Source§

impl<S: Clone + State> Clone for Pattern<S>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug + State> Debug for Pattern<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: State> From<Group<S>> for Pattern<S>

Source§

fn from(group: Group<S>) -> Self

Converts to this type from the input type.
Source§

impl<S: State> From<Literal<S>> for Pattern<S>

Source§

fn from(group: Literal<S>) -> Self

Converts to this type from the input type.
Source§

impl<S: State> From<Set<S>> for Pattern<S>

Source§

fn from(group: Set<S>) -> Self

Converts to this type from the input type.
Source§

impl<S: State> From<Special<S>> for Pattern<S>

Source§

fn from(group: Special<S>) -> Self

Converts to this type from the input type.
Source§

impl<S: PartialEq + State> PartialEq for Pattern<S>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<S: PartialEq + State> StructuralPartialEq for Pattern<S>

Auto Trait Implementations§

§

impl<S> Forget for Pattern<S>

§

impl<S> Freeze for Pattern<S>
where Group<S>: Freeze, Set<S>: Freeze, Special<S>: Freeze, Literal<S>: Freeze,

§

impl<S> Move for Pattern<S>

§

impl<S> RefUnwindSafe for Pattern<S>

§

impl<S> Send for Pattern<S>
where Group<S>: Send, Set<S>: Send, Special<S>: Send, Literal<S>: Send,

§

impl<S> Sync for Pattern<S>
where Group<S>: Sync, Set<S>: Sync, Special<S>: Sync, Literal<S>: Sync,

§

impl<S> Unpin for Pattern<S>
where Group<S>: Unpin, Set<S>: Unpin, Special<S>: Unpin, Literal<S>: Unpin,

§

impl<S> UnsafeUnpin for Pattern<S>

§

impl<S> UnwindSafe for Pattern<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Is for T
where T: ?Sized,

Source§

type EqTo = T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.