2014-07-18 13:56:17 +00:00
|
|
|
// Rust Bitcoin Library
|
|
|
|
// Written in 2014 by
|
|
|
|
// Andrew Poelstra <apoelstra@wpsoftware.net>
|
|
|
|
//
|
|
|
|
// To the extent possible under law, the author(s) have dedicated all
|
|
|
|
// copyright and related and neighboring rights to this software to
|
|
|
|
// the public domain worldwide. This software is distributed without
|
|
|
|
// any warranty.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the CC0 Public Domain Dedication
|
|
|
|
// along with this software.
|
|
|
|
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
|
|
//
|
|
|
|
|
|
|
|
//! # Utility functions
|
|
|
|
//!
|
|
|
|
//! Functions needed by all parts of the Bitcoin library
|
|
|
|
|
2014-08-25 06:03:47 +00:00
|
|
|
pub mod base58;
|
2014-07-18 19:39:11 +00:00
|
|
|
pub mod error;
|
2014-07-18 13:56:17 +00:00
|
|
|
pub mod hash;
|
|
|
|
pub mod iter;
|
|
|
|
pub mod misc;
|
|
|
|
pub mod patricia_tree;
|
|
|
|
pub mod uint;
|
|
|
|
|
|
|
|
/// A trait which allows numbers to act as fixed-size bit arrays
|
|
|
|
pub trait BitArray {
|
|
|
|
/// Is bit set?
|
2015-01-18 18:16:01 +00:00
|
|
|
fn bit(&self, idx: usize) -> bool;
|
2014-07-18 13:56:17 +00:00
|
|
|
|
|
|
|
/// Returns an array which is just the bits from start to end
|
2015-01-18 18:16:01 +00:00
|
|
|
fn bit_slice(&self, start: usize, end: usize) -> Self;
|
2014-07-18 13:56:17 +00:00
|
|
|
|
|
|
|
/// Bitwise and with `n` ones
|
2015-01-18 18:16:01 +00:00
|
|
|
fn mask(&self, n: usize) -> Self;
|
2014-07-18 13:56:17 +00:00
|
|
|
|
|
|
|
/// Trailing zeros
|
2015-01-18 18:16:01 +00:00
|
|
|
fn trailing_zeros(&self) -> usize;
|
2014-07-18 13:56:17 +00:00
|
|
|
}
|
|
|
|
|