parent
e28368ff1b
commit
271e17547a
|
@ -1,6 +1,8 @@
|
||||||
use crate::{hash::hashv, program_utils::DecodeError};
|
use crate::{hash::hashv, program_utils::DecodeError};
|
||||||
use num_derive::{FromPrimitive, ToPrimitive};
|
use num_derive::{FromPrimitive, ToPrimitive};
|
||||||
use std::{convert::TryFrom, error, fmt, mem, str::FromStr};
|
#[cfg(not(feature = "program"))]
|
||||||
|
use std::error;
|
||||||
|
use std::{convert::TryFrom, fmt, mem, str::FromStr};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
pub use bs58;
|
pub use bs58;
|
||||||
|
@ -13,7 +15,6 @@ pub enum PubkeyError {
|
||||||
#[error("length of requested seed is too long")]
|
#[error("length of requested seed is too long")]
|
||||||
MaxSeedLengthExceeded,
|
MaxSeedLengthExceeded,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> DecodeError<T> for PubkeyError {
|
impl<T> DecodeError<T> for PubkeyError {
|
||||||
fn type_of() -> &'static str {
|
fn type_of() -> &'static str {
|
||||||
"PubkeyError"
|
"PubkeyError"
|
||||||
|
@ -24,20 +25,19 @@ impl<T> DecodeError<T> for PubkeyError {
|
||||||
#[derive(Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
#[derive(Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||||
pub struct Pubkey([u8; 32]);
|
pub struct Pubkey([u8; 32]);
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Error, Debug, Serialize, Clone, PartialEq, FromPrimitive, ToPrimitive)]
|
||||||
pub enum ParsePubkeyError {
|
pub enum ParsePubkeyError {
|
||||||
|
#[error("String is the wrong size")]
|
||||||
WrongSize,
|
WrongSize,
|
||||||
|
#[error("Invalid Base58 string")]
|
||||||
Invalid,
|
Invalid,
|
||||||
}
|
}
|
||||||
|
impl<T> DecodeError<T> for ParsePubkeyError {
|
||||||
impl fmt::Display for ParsePubkeyError {
|
fn type_of() -> &'static str {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
"ParsePubkeyError"
|
||||||
write!(f, "ParsePubkeyError: {:?}", self)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl error::Error for ParsePubkeyError {}
|
|
||||||
|
|
||||||
impl FromStr for Pubkey {
|
impl FromStr for Pubkey {
|
||||||
type Err = ParsePubkeyError;
|
type Err = ParsePubkeyError;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue