use crate::merkle::{mem::Mem, Error, Family, Position};
use commonware_cryptography::Digest;
use core::future::Future;
pub trait Storage<F: Family>: Send + Sync {
type Digest: Digest;
fn size(&self) -> impl Future<Output = Position<F>> + Send;
fn get_node(
&self,
position: Position<F>,
) -> impl Future<Output = Result<Option<Self::Digest>, Error<F>>> + Send;
}
impl<F, D> Storage<F> for Mem<F, D>
where
F: Family,
D: Digest,
{
type Digest = D;
async fn size(&self) -> Position<F> {
self.size()
}
async fn get_node(&self, position: Position<F>) -> Result<Option<D>, Error<F>> {
Ok(Self::get_node(self, position))
}
}