Add trait for PSBT key-value maps
This commit is contained in:
parent
528e39334c
commit
2715a6e777
|
@ -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>;
|
||||
}
|
|
@ -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};
|
||||
|
|
Loading…
Reference in New Issue