pub trait Storage: Send + Sync + 'static + Sized {
// Required methods
fn name() -> &'static str
where Self: Sized;
fn open<'async_trait>(
path: impl 'async_trait + Into<PathBuf> + Send
) -> Pin<Box<dyn Future<Output = KernelResult<Self>> + Send + 'async_trait>>
where Self: 'async_trait;
fn flush<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = KernelResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn set<'life0, 'async_trait>(
&'life0 self,
key: Bytes,
value: Bytes
) -> Pin<Box<dyn Future<Output = KernelResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = KernelResult<Option<Bytes>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = KernelResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn size_of_disk<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = KernelResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn len<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = KernelResult<usize>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn is_empty<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
KV持久化内核 操作定义
Required Methods§
sourcefn open<'async_trait>(
path: impl 'async_trait + Into<PathBuf> + Send
) -> Pin<Box<dyn Future<Output = KernelResult<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
fn open<'async_trait>(
path: impl 'async_trait + Into<PathBuf> + Send
) -> Pin<Box<dyn Future<Output = KernelResult<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
通过数据目录路径开启数据库
sourcefn flush<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = KernelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn flush<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = KernelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
强制将数据刷入硬盘
sourcefn set<'life0, 'async_trait>(
&'life0 self,
key: Bytes,
value: Bytes
) -> Pin<Box<dyn Future<Output = KernelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set<'life0, 'async_trait>(
&'life0 self,
key: Bytes,
value: Bytes
) -> Pin<Box<dyn Future<Output = KernelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
设置键值对
sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = KernelResult<Option<Bytes>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = KernelResult<Option<Bytes>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
通过键获取对应的值
sourcefn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = KernelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = KernelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
通过键删除键值对
fn size_of_disk<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = KernelResult<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn len<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = KernelResult<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn is_empty<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Object Safety§
This trait is not object safe.