use crate::StateRead;
use std::{any::Any, collections::BTreeMap};
use tendermint::abci;
pub trait StateWrite: StateRead + Send + Sync {
fn put_raw(&mut self, key: String, value: Vec<u8>);
fn delete(&mut self, key: String);
fn nonverifiable_put_raw(&mut self, key: Vec<u8>, value: Vec<u8>);
fn nonverifiable_delete(&mut self, key: Vec<u8>);
fn object_put<T: Clone + Any + Send + Sync>(&mut self, key: &'static str, value: T);
fn object_delete(&mut self, key: &'static str);
fn object_merge(&mut self, objects: BTreeMap<&'static str, Option<Box<dyn Any + Send + Sync>>>);
fn record(&mut self, event: abci::Event);
}
impl<'a, S: StateWrite + Send + Sync> StateWrite for &'a mut S {
fn put_raw(&mut self, key: String, value: jmt::OwnedValue) {
(**self).put_raw(key, value)
}
fn delete(&mut self, key: String) {
(**self).delete(key)
}
fn nonverifiable_delete(&mut self, key: Vec<u8>) {
(**self).nonverifiable_delete(key)
}
fn nonverifiable_put_raw(&mut self, key: Vec<u8>, value: Vec<u8>) {
(**self).nonverifiable_put_raw(key, value)
}
fn object_put<T: Clone + Any + Send + Sync>(&mut self, key: &'static str, value: T) {
(**self).object_put(key, value)
}
fn object_delete(&mut self, key: &'static str) {
(**self).object_delete(key)
}
fn object_merge(
&mut self,
objects: BTreeMap<&'static str, Option<Box<dyn Any + Send + Sync>>>,
) {
(**self).object_merge(objects)
}
fn record(&mut self, event: abci::Event) {
(**self).record(event)
}
}