ayun-storage 0.22.1

The RUST Framework for Web Rustceans.
Documentation
use super::{GetResponse, PutResponse, StorageResult, StoreDriver};
use crate::Error;
use async_trait::async_trait;
use bytes::Bytes;
use std::path::Path;

pub struct NullStorage;

pub fn new() -> Box<dyn StoreDriver> {
    Box::new(NullStorage {})
}

#[async_trait]
impl StoreDriver for NullStorage {
    async fn put(&self, _path: &Path, _content: &Bytes) -> StorageResult<PutResponse> {
        Err(Error::Message(
            "Operation not supported by null storage".into(),
        ))
    }

    async fn get(&self, _path: &Path) -> StorageResult<GetResponse> {
        Err(Error::Message(
            "Operation not supported by null storage".into(),
        ))
    }

    async fn delete(&self, _path: &Path) -> StorageResult<()> {
        Err(Error::Message(
            "Operation not supported by null storage".into(),
        ))
    }

    async fn rename(&self, _from: &Path, _to: &Path) -> StorageResult<()> {
        Err(Error::Message(
            "Operation not supported by null storage".into(),
        ))
    }

    async fn copy(&self, _from: &Path, _to: &Path) -> StorageResult<()> {
        Err(Error::Message(
            "Operation not supported by null storage".into(),
        ))
    }

    async fn exists(&self, _path: &Path) -> StorageResult<bool> {
        Err(Error::Message(
            "Operation not supported by null storage".into(),
        ))
    }
}