Use `zeroize_derive` feature instead of impl zeroize
This commit is contained in:
parent
a298344178
commit
bb0f63298a
|
@ -46,7 +46,7 @@ rand_core = "0.4.0"
|
||||||
unicode-normalization = { version = "=0.1.9", optional = true }
|
unicode-normalization = { version = "=0.1.9", optional = true }
|
||||||
rand = { version = "0.6.0", optional = true }
|
rand = { version = "0.6.0", optional = true }
|
||||||
serde = { version = "1.0", default-features = false, optional = true }
|
serde = { version = "1.0", default-features = false, optional = true }
|
||||||
zeroize = {version = "1.2", optional = true}
|
zeroize = {version = "1.2", features = ["zeroize_derive"], optional = true}
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = { version = "0.6.0", optional = false }
|
rand = { version = "0.6.0", optional = false }
|
||||||
|
|
|
@ -55,6 +55,12 @@ pub enum Language {
|
||||||
Spanish,
|
Spanish,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Language {
|
||||||
|
fn default() -> Self {
|
||||||
|
Language::English
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Language {
|
impl Language {
|
||||||
/// The list of supported languages.
|
/// The list of supported languages.
|
||||||
/// Language support is managed by compile features.
|
/// Language support is managed by compile features.
|
||||||
|
|
|
@ -157,6 +157,7 @@ impl error::Error for Error {}
|
||||||
///
|
///
|
||||||
/// Supported number of words are 12, 18 and 24.
|
/// Supported number of words are 12, 18 and 24.
|
||||||
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
#[cfg_attr(feature = "zeroize", derive(Zeroize), zeroize(drop))]
|
||||||
pub struct Mnemonic {
|
pub struct Mnemonic {
|
||||||
/// The language the mnemonic.
|
/// The language the mnemonic.
|
||||||
lang: Language,
|
lang: Language,
|
||||||
|
@ -166,11 +167,7 @@ pub struct Mnemonic {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "zeroize")]
|
#[cfg(feature = "zeroize")]
|
||||||
impl Zeroize for Mnemonic {
|
impl zeroize::DefaultIsZeroes for Language {}
|
||||||
fn zeroize(&mut self) {
|
|
||||||
self.words.zeroize()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
serde_string_impl!(Mnemonic, "a BIP-39 Mnemonic Code");
|
serde_string_impl!(Mnemonic, "a BIP-39 Mnemonic Code");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue