mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-16 03:21:22 +00:00
refactor(identity): follow naming conventions for conversion methods
This PR renames some method names that don't follow Rust naming conventions or behave differently from what the name suggests: - Enforce "try" prefix on all methods that return `Result`. - Enforce "encode" method name for methods that return encoded bytes. - Enforce "to_bytes" method name for methods that return raw bytes. - Enforce "decode" method name for methods that convert encoded key. - Enforce "from_bytes" method name for methods that convert raw bytes. Pull-Request: #3775.
This commit is contained in:
@ -121,7 +121,27 @@ impl From<&PublicKey> for proto::PublicKey {
|
||||
}
|
||||
}
|
||||
|
||||
pub use error::{DecodingError, SigningError};
|
||||
pub use error::{DecodingError, OtherVariantError, SigningError};
|
||||
pub use keypair::{Keypair, PublicKey};
|
||||
#[cfg(feature = "peerid")]
|
||||
pub use peer_id::{ParseError, PeerId};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
/// The type of key a `KeyPair` is holding.
|
||||
pub enum KeyType {
|
||||
Ed25519,
|
||||
RSA,
|
||||
Secp256k1,
|
||||
Ecdsa,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for KeyType {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
KeyType::Ed25519 => f.write_str("Ed25519"),
|
||||
KeyType::RSA => f.write_str("RSA"),
|
||||
KeyType::Secp256k1 => f.write_str("Secp256k1"),
|
||||
KeyType::Ecdsa => f.write_str("Ecdsa"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user