zeldhash_protocol/
store.rs

1use crate::types::{Amount, UtxoKey};
2
3/// Abstraction over the persistence layer used by `ZeldProtocol`.
4///
5/// Any backend that can read and write ZELD balances using the provided key can
6/// be used. Higher-level lifecycle management (transactions, staging, etc.) is
7/// left to concrete implementations.
8pub trait ZeldStore {
9    /// Fetches the ZELD balance attached to a given UTXO key.
10    fn get(&mut self, key: &UtxoKey) -> Amount;
11
12    /// Removes the entry for the UTXO key, returning its current ZELD balance.
13    /// Implementations should return `0` if the key is not present.
14    fn pop(&mut self, key: &UtxoKey) -> Amount;
15
16    /// Sets the ZELD balance assigned to a UTXO key.
17    fn set(&mut self, key: UtxoKey, value: Amount);
18}