soph_storage/support/drivers/
null.rs

1use super::{GetResponse, PutResponse, StorageResult, StoreDriver};
2use crate::{async_trait, error::Error};
3use bytes::Bytes;
4use std::path::Path;
5
6pub struct NullStorage;
7
8pub fn new() -> Box<dyn StoreDriver> {
9    Box::new(NullStorage {})
10}
11
12#[async_trait]
13impl StoreDriver for NullStorage {
14    async fn put(&self, _path: &Path, _content: &Bytes) -> StorageResult<PutResponse> {
15        Err(Error::Message("Operation not supported by null storage".into()))
16    }
17
18    async fn get(&self, _path: &Path) -> StorageResult<GetResponse> {
19        Err(Error::Message("Operation not supported by null storage".into()))
20    }
21
22    async fn delete(&self, _path: &Path) -> StorageResult<()> {
23        Err(Error::Message("Operation not supported by null storage".into()))
24    }
25
26    async fn rename(&self, _from: &Path, _to: &Path) -> StorageResult<()> {
27        Err(Error::Message("Operation not supported by null storage".into()))
28    }
29
30    async fn copy(&self, _from: &Path, _to: &Path) -> StorageResult<()> {
31        Err(Error::Message("Operation not supported by null storage".into()))
32    }
33
34    async fn exists(&self, _path: &Path) -> StorageResult<bool> {
35        Err(Error::Message("Operation not supported by null storage".into()))
36    }
37}