use derive_new::new;
use log::{debug, trace};
use crate::BoundRange;
use crate::Key;
use crate::KvPair;
use crate::Result;
use crate::Transaction;
use crate::Value;
#[derive(new)]
pub struct Snapshot {
transaction: Transaction,
}
impl Snapshot {
pub async fn get(&mut self, key: impl Into<Key>) -> Result<Option<Value>> {
trace!("invoking get request on snapshot");
self.transaction.get(key).await
}
pub async fn key_exists(&mut self, key: impl Into<Key>) -> Result<bool> {
debug!("invoking key_exists request on snapshot");
self.transaction.key_exists(key).await
}
pub async fn batch_get(
&mut self,
keys: impl IntoIterator<Item = impl Into<Key>>,
) -> Result<impl Iterator<Item = KvPair>> {
debug!("invoking batch_get request on snapshot");
self.transaction.batch_get(keys).await
}
pub async fn scan(
&mut self,
range: impl Into<BoundRange>,
limit: u32,
) -> Result<impl Iterator<Item = KvPair>> {
debug!("invoking scan request on snapshot");
self.transaction.scan(range, limit).await
}
pub async fn scan_keys(
&mut self,
range: impl Into<BoundRange>,
limit: u32,
) -> Result<impl Iterator<Item = Key>> {
debug!("invoking scan_keys request on snapshot");
self.transaction.scan_keys(range, limit).await
}
pub async fn scan_reverse(
&mut self,
range: impl Into<BoundRange>,
limit: u32,
) -> Result<impl Iterator<Item = KvPair>> {
debug!("invoking scan_reverse request on snapshot");
self.transaction.scan_reverse(range, limit).await
}
pub async fn scan_keys_reverse(
&mut self,
range: impl Into<BoundRange>,
limit: u32,
) -> Result<impl Iterator<Item = Key>> {
debug!("invoking scan_keys_reverse request on snapshot");
self.transaction.scan_keys_reverse(range, limit).await
}
}