Lines
50 %
Functions
61.54 %
Branches
100 %
use async_trait::async_trait;
use super::{KeyOperation, KeyValue, Output};
use crate::Error;
/// A namespaced key-value store. All operations performed with this will be
/// separate from other namespaces.
pub struct Namespaced<'a, K> {
namespace: String,
kv: &'a K,
}
impl<'a, K> Namespaced<'a, K> {
pub(crate) const fn new(namespace: String, kv: &'a K) -> Self {
Self { namespace, kv }
#[async_trait]
impl<'a, K> KeyValue for Namespaced<'a, K>
where
K: KeyValue,
{
async fn execute_key_operation(&self, op: KeyOperation) -> Result<Output, Error> {
self.kv.execute_key_operation(op).await
fn key_namespace(&self) -> Option<&'_ str> {
Some(&self.namespace)
fn with_key_namespace(&'_ self, namespace: &str) -> Namespaced<'_, Self>
Self: Sized,
Namespaced {
namespace: format!("{}\u{0}{}", self.namespace, namespace),
kv: self,