use core::future::Future;
use fusio_core::MaybeSend;
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum DurabilityLevel {
None,
Flush,
Data,
All,
Commit,
}
use crate::{error::Error, path::Path};
pub trait FileSync: MaybeSend {
fn sync_data(&mut self) -> impl Future<Output = Result<(), Error>> + MaybeSend;
fn sync_all(&mut self) -> impl Future<Output = Result<(), Error>> + MaybeSend;
fn sync_range(
&mut self,
_offset: u64,
_len: u64,
) -> impl Future<Output = Result<(), Error>> + MaybeSend;
}
pub trait FileCommit: MaybeSend {
fn commit(&mut self) -> impl Future<Output = Result<(), Error>> + MaybeSend;
}
pub trait DirSync: MaybeSend {
fn sync_parent(&self, path: &Path) -> impl Future<Output = Result<(), Error>> + MaybeSend;
}
pub trait DirSyncExt: DirSync {
fn dirsync_parent(&self, path: &Path) -> impl Future<Output = Result<(), Error>> + MaybeSend {
self.sync_parent(path)
}
}
impl<T: DirSync + ?Sized> DirSyncExt for T {}