use std::fmt::Debug;
#[async_trait::async_trait]
pub trait Backup {
type Config;
type Error: Send + Sync;
async fn backup(&self, config: Self::Config) -> Result<(), Self::Error>;
async fn has_backup(&self, config: Self::Config) -> bool;
async fn try_restore(&mut self, config: Self::Config) -> Result<(), Self::Error>;
}
#[async_trait::async_trait]
pub trait Export {
type Error: Send + Sync + Debug;
async fn export(&self) -> Result<Vec<u8>, Self::Error>;
}
#[async_trait::async_trait]
impl Export for () {
type Error = ();
async fn export(&self) -> Result<Vec<u8>, Self::Error> {
Ok(vec![])
}
}
#[async_trait::async_trait]
pub trait Import: Sized {
type Error: Send + Sync + Debug;
async fn import(data: Vec<u8>) -> Result<Self, Self::Error>;
}
#[async_trait::async_trait]
impl Import for () {
type Error = ();
async fn import(_data: Vec<u8>) -> Result<Self, Self::Error> {
Ok(())
}
}