use std::collections::BTreeMap;
use borsh::{BorshDeserialize, BorshSerialize};
use namada_core::borsh::BorshSerializeExt;
use namada_core::hash::Hash;
pub use regex::Regex;
pub type KVBytes = (Box<[u8]>, Box<[u8]>);
pub struct PrefixIterator<I> {
pub iter: I,
pub stripped_prefix: String,
}
impl<I> PrefixIterator<I> {
pub fn new<E>(iter: I, stripped_prefix: String) -> Self
where
E: std::error::Error,
I: Iterator<Item = std::result::Result<KVBytes, E>>,
{
PrefixIterator {
iter,
stripped_prefix,
}
}
}
impl<I> std::fmt::Debug for PrefixIterator<I> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("PrefixIterator")
}
}
pub struct PatternIterator<I> {
pub iter: I,
pub pattern: Regex,
}
impl<I> PatternIterator<I> {
pub fn new<E>(iter: I, pattern: Regex) -> Self
where
E: std::error::Error,
I: Iterator<Item = Result<KVBytes, E>>,
{
Self { iter, pattern }
}
}
impl<I> std::fmt::Debug for PatternIterator<I> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("PatternIterator")
}
}
#[derive(Debug, BorshSerialize, BorshDeserialize, Default)]
pub struct CommitOnlyData {
pub tx_gas: BTreeMap<Hash, u64>,
}
impl CommitOnlyData {
pub fn serialize(&self) -> Vec<u8> {
self.serialize_to_vec()
}
}