pub mod address;
pub mod amount;
pub mod base58;
pub mod bip143;
pub mod bip158;
pub mod bip32;
pub mod contracthash;
pub mod hash;
pub mod key;
pub mod merkleblock;
pub mod misc;
pub mod psbt;
pub mod uint;
pub mod signature;
pub mod prime;
pub mod rfc6979;
pub(crate) mod endian;
use std::{error, fmt};
use crate::consensus::encode;
use crate::network;
pub trait BitArray {
fn bit(&self, idx: usize) -> bool;
fn bit_slice(&self, start: usize, end: usize) -> Self;
fn mask(&self, n: usize) -> Self;
fn trailing_zeros(&self) -> usize;
fn zero() -> Self;
fn one() -> Self;
}
#[derive(Debug)]
pub enum Error {
Encode(encode::Error),
Network(network::Error),
Signature(signature::Error),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::Encode(ref e) => fmt::Display::fmt(e, f),
Error::Network(ref e) => fmt::Display::fmt(e, f),
Error::Signature(ref e) => fmt::Display::fmt(e, f),
}
}
}
#[allow(deprecated)]
impl error::Error for Error {
fn cause(&self) -> Option<&dyn error::Error> {
match *self {
Error::Encode(ref e) => Some(e),
Error::Network(ref e) => Some(e),
Error::Signature(ref e) => Some(e),
}
}
fn description(&self) -> &str {
"description() is deprecated; use Display"
}
}
#[doc(hidden)]
impl From<encode::Error> for Error {
fn from(e: encode::Error) -> Error {
Error::Encode(e)
}
}
#[doc(hidden)]
impl From<network::Error> for Error {
fn from(e: network::Error) -> Error {
Error::Network(e)
}
}