Skip to main content

secure_exec_vfs_core/engine/
block.rs

1use crate::engine::error::VfsResult;
2use crate::engine::types::{BlockKey, ObjectEntry, ObjectMeta};
3use async_trait::async_trait;
4
5#[async_trait]
6pub trait BlockStore: Send + Sync {
7    async fn get(&self, key: &BlockKey) -> VfsResult<Vec<u8>>;
8    async fn get_range(&self, key: &BlockKey, off: u64, len: u64) -> VfsResult<Vec<u8>>;
9    async fn put(&self, key: &BlockKey, data: &[u8]) -> VfsResult<()>;
10    async fn exists(&self, key: &BlockKey) -> VfsResult<bool>;
11    async fn delete_many(&self, keys: &[BlockKey]) -> VfsResult<()>;
12    async fn copy(&self, src: &BlockKey, dst: &BlockKey) -> VfsResult<()>;
13}
14
15#[async_trait]
16pub trait ObjectBackend: Send + Sync {
17    async fn list(&self, prefix: &str) -> VfsResult<Vec<ObjectEntry>>;
18    async fn head(&self, key: &str) -> VfsResult<Option<ObjectMeta>>;
19    async fn get_range(&self, key: &str, off: u64, len: u64) -> VfsResult<Vec<u8>>;
20    async fn put(&self, key: &str, data: &[u8], meta: ObjectMeta) -> VfsResult<()>;
21    async fn copy(&self, src: &str, dst: &str) -> VfsResult<()>;
22    async fn delete(&self, key: &str) -> VfsResult<()>;
23}