Add testing NoSerde operator (#9)

This commit is contained in:
Daniel Sanchez 2022-11-21 15:15:28 +01:00 committed by GitHub
parent 61de96a5d3
commit ece4b90550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 0 deletions

View File

@ -47,3 +47,30 @@ pub trait StorageBackend {
transaction: Self::Transaction,
) -> Result<<Self::Transaction as StorageTransaction>::Result, Self::Error>;
}
#[cfg(test)]
pub mod testing {
use crate::storage::backends::StorageSerde;
use bytes::Bytes;
use serde::de::DeserializeOwned;
use serde::Serialize;
use thiserror::Error;
pub struct NoStorageSerde;
#[derive(Error, Debug)]
#[error("Fake error")]
pub struct NoError;
impl StorageSerde for NoStorageSerde {
type Error = NoError;
fn serialize<T: Serialize>(_value: T) -> Bytes {
Bytes::new()
}
fn deserialize<T: DeserializeOwned>(_buff: Bytes) -> Result<T, Self::Error> {
Err(NoError)
}
}
}