Add trait for PSBT key-value maps

This commit is contained in:
Carl Dong 2018-09-08 20:50:45 -07:00
parent 528e39334c
commit 2715a6e777
2 changed files with 18 additions and 0 deletions

15
src/util/psbt/map/mod.rs Normal file
View File

@ -0,0 +1,15 @@
use consensus::encode;
use util::psbt;
use util::psbt::raw;
/// A trait that describes a PSBT key-value map.
pub trait Map {
/// Attempt to insert a key-value pair.
fn insert_pair(&mut self, pair: raw::Pair) -> Result<(), encode::Error>;
/// Attempt to get all key-value pairs.
fn get_pairs(&self) -> Result<Vec<raw::Pair>, encode::Error>;
/// Attempt to merge with another key-value map of the same type.
fn merge(&mut self, other: Self) -> Result<(), psbt::Error>;
}

View File

@ -9,6 +9,9 @@ pub use self::error::Error;
pub mod raw;
mod map;
pub use self::map::Map;
#[cfg(test)]
mod tests {
use consensus::encode::{deserialize, serialize};