zcash_address: Introduce UA-specific parser error type
This commit is contained in:
parent
01a8dba450
commit
cd94b41d61
|
@ -13,6 +13,14 @@ pub enum ParseError {
|
||||||
NotZcash,
|
NotZcash,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<unified::ParseError> for ParseError {
|
||||||
|
fn from(e: unified::ParseError) -> Self {
|
||||||
|
match e {
|
||||||
|
unified::ParseError::InvalidEncoding => Self::InvalidEncoding,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for ParseError {
|
impl fmt::Display for ParseError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use std::convert::{TryFrom, TryInto};
|
use std::convert::{TryFrom, TryInto};
|
||||||
|
use std::error::Error;
|
||||||
|
use std::fmt;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use crate::{kind, ParseError};
|
use crate::kind;
|
||||||
|
|
||||||
mod f4jumble;
|
mod f4jumble;
|
||||||
|
|
||||||
|
@ -57,6 +59,23 @@ impl From<Typecode> for u8 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An error while attempting to parse a string as a Zcash address.
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub enum ParseError {
|
||||||
|
/// The string is an invalid encoding.
|
||||||
|
InvalidEncoding,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for ParseError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
ParseError::InvalidEncoding => write!(f, "Invalid encoding"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error for ParseError {}
|
||||||
|
|
||||||
/// The set of known Receivers for Unified Addresses.
|
/// The set of known Receivers for Unified Addresses.
|
||||||
///
|
///
|
||||||
/// This enum is an internal-only type, and is maintained in preference order, so that the
|
/// This enum is an internal-only type, and is maintained in preference order, so that the
|
||||||
|
|
Loading…
Reference in New Issue