pub trait Mnemonic {
    type Language;
    type MnemonicType;
    type MnemonicBuilder;
    type Mnemonic;
    type ErrorType;

    // Required methods
    fn new(
        language: Self::Language,
        mnemonic_type: Self::MnemonicType,
        passphrase: Option<&str>
    ) -> Self::Mnemonic;
    fn from_phrase(
        language: Self::Language,
        phrase: &str,
        specified_passphrase: Option<&str>
    ) -> Result<Self::Mnemonic, Self::ErrorType>;
    fn detect_language(
        phrase: &str,
        specified_passphrase: Option<&str>
    ) -> Result<Self::Mnemonic, Self::ErrorType>;
    fn builder() -> Self::MnemonicBuilder;
    fn to_seed(&self) -> Seed;
    fn language(&self) -> Self::Language;
    fn phrase(&self) -> String;
    fn mnemonic_type(&self) -> Self::MnemonicType;
}
Expand description

Provide a common interface for different mnemonic protocols.

Required Associated Types§

type Language

The associated Language struct

type MnemonicType

The associated MnemonicType struct

type MnemonicBuilder

The associated Builder struct for the Mnemonic

type Mnemonic

type ErrorType

Required Methods§

fn new( language: Self::Language, mnemonic_type: Self::MnemonicType, passphrase: Option<&str> ) -> Self::Mnemonic

Generates a new mnemonic given the language, mnemonic type, and an optional passphrase.

fn from_phrase( language: Self::Language, phrase: &str, specified_passphrase: Option<&str> ) -> Result<Self::Mnemonic, Self::ErrorType>

Recovers a mnemonic given the given the language, mnemonic type, and an optional passphrase.

fn detect_language( phrase: &str, specified_passphrase: Option<&str> ) -> Result<Self::Mnemonic, Self::ErrorType>

Recovers a mnemonic given the mnemonic phrase and optional passphrase, attempts to auto detect the language of the mnemonic phrase. Returns an error if the language cannot be detected or the provided mnemonic phrase was invalid.

fn builder() -> Self::MnemonicBuilder

Returns the builder for the mnemonic.

fn to_seed(&self) -> Seed

Returns the seed associated with the mnemonic phrase.

fn language(&self) -> Self::Language

fn phrase(&self) -> String

fn mnemonic_type(&self) -> Self::MnemonicType

Implementors§