Struct deep_space::mnemonic::Mnemonic
source · [−]pub struct Mnemonic(_);Expand description
A mnemonic code.
The std::str::FromStr implementation will try to determine the language of the mnemonic from all the supported languages. (Languages have to be explicitly enabled using the Cargo features.)
Supported number of words are 12, 18 and 24.
Implementations
sourceimpl Mnemonic
impl Mnemonic
sourcepub fn from_entropy_in(
language: Language,
entropy: &[u8]
) -> Result<Mnemonic, Bip39Error>
pub fn from_entropy_in(
language: Language,
entropy: &[u8]
) -> Result<Mnemonic, Bip39Error>
Create a new Mnemonic in the specified language from the given entropy. Entropy must be a multiple of 32 bits (4 bytes) and 128-256 bits in length.
sourcepub fn from_entropy(entropy: &[u8]) -> Result<Mnemonic, Bip39Error>
pub fn from_entropy(entropy: &[u8]) -> Result<Mnemonic, Bip39Error>
Create a new English Mnemonic in from the given entropy. Entropy must be a multiple of 32 bits (4 bytes) and 128-256 bits in length.
sourcepub fn generate_in(
language: Language,
word_count: usize
) -> Result<Mnemonic, Bip39Error>
pub fn generate_in(
language: Language,
word_count: usize
) -> Result<Mnemonic, Bip39Error>
Generate a new Mnemonic in the given language. For the different supported word counts, see documentation on [Mnemonoc].
sourcepub fn generate(word_count: usize) -> Result<Mnemonic, Bip39Error>
pub fn generate(word_count: usize) -> Result<Mnemonic, Bip39Error>
Generate a new Mnemonic in English. For the different supported word counts, see documentation on [Mnemonoc].
sourcepub fn validate_in(language: Language, s: &str) -> Result<(), Bip39Error>
pub fn validate_in(language: Language, s: &str) -> Result<(), Bip39Error>
Static method to validate a mnemonic in a given language.
sourcepub fn language_of(s: &str) -> Result<Language, Bip39Error>
pub fn language_of(s: &str) -> Result<Language, Bip39Error>
Determine the language of the mnemonic.
NOTE: This method only guarantees that the returned language is the correct language on the assumption that the mnemonic is valid. It does not itself validate the mnemonic.
Some word lists don’t guarantee that their words don’t occur in other word lists. In the extremely unlikely case that a word list can be interpreted in multiple languages, an [Error::AmbiguousWordList] is returned, containing the possible languages.
sourcepub fn parse<'a, S: Into<Cow<'a, str>>>(s: S) -> Result<Mnemonic, Bip39Error>
pub fn parse<'a, S: Into<Cow<'a, str>>>(s: S) -> Result<Mnemonic, Bip39Error>
Parse a mnemonic and detect the language from the enabled languages.
sourcepub fn parse_in<'a, S: Into<Cow<'a, str>>>(
language: Language,
s: S
) -> Result<Mnemonic, Bip39Error>
pub fn parse_in<'a, S: Into<Cow<'a, str>>>(
language: Language,
s: S
) -> Result<Mnemonic, Bip39Error>
Parse a mnemonic in the given language.
sourcepub fn word_count(&self) -> usize
pub fn word_count(&self) -> usize
Get the number of words in the mnemonic.
sourcepub fn to_entropy(&self) -> Vec<u8>
pub fn to_entropy(&self) -> Vec<u8>
Convert the mnemonic back to the entropy used to generate it.
Trait Implementations
sourceimpl FromStr for Mnemonic
impl FromStr for Mnemonic
type Err = Bip39Error
type Err = Bip39Error
The associated error which can be returned from parsing.
sourceimpl Ord for Mnemonic
impl Ord for Mnemonic
sourceimpl PartialOrd<Mnemonic> for Mnemonic
impl PartialOrd<Mnemonic> for Mnemonic
sourcefn partial_cmp(&self, other: &Mnemonic) -> Option<Ordering>
fn partial_cmp(&self, other: &Mnemonic) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
impl Eq for Mnemonic
impl StructuralEq for Mnemonic
impl StructuralPartialEq for Mnemonic
Auto Trait Implementations
impl RefUnwindSafe for Mnemonic
impl Send for Mnemonic
impl Sync for Mnemonic
impl Unpin for Mnemonic
impl UnwindSafe for Mnemonic
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key and return true if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message T in a tonic::Request
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more