use std::io::Result;
use crate::SegmentId;
use crate::segment;
use crate::config::HyperFileMetaConfig;
use crate::staging::config::StagingConfig;
use crate::inode::{OnDiskState, FlushInodeFlag};
pub trait StagingIntercept<Staging>: Send + Sync {
fn before_flush_inode(&self, staging: &Staging, payload: &[u8], flag: FlushInodeFlag) -> std::pin::Pin<Box<dyn Future<Output = Result<()>> + '_ + Send>> {
let _ = (staging, payload, flag);
Box::pin(async { Ok(()) })
}
fn after_flush_inode(&self, staging: &Staging, payload: &[u8], flag: FlushInodeFlag) -> std::pin::Pin<Box<dyn Future<Output = Result<()>> + '_ + Send>>;
fn after_remove_inode(&self, staging: &Staging) -> std::pin::Pin<Box<dyn Future<Output = Result<()>> + '_ + Send>>;
fn before_segment_done(&self, staging: &Staging, segid: crate::SegmentId, buf: &[u8], len: usize) -> std::pin::Pin<Box<dyn Future<Output = Result<()>> + '_ + Send>> {
let _ = (staging, segid, buf, len);
Box::pin(async { Ok(()) })
}
}
pub trait Staging<L> {
fn read_timing(&self) -> &crate::file::ReadTiming;
fn load_inode(&self, buf: &mut [u8]) -> impl Future<Output = Result<Option<OnDiskState>>>;
fn load_inode_from_segment(&self, buf: &mut [u8], segid: u64) -> impl Future<Output = Result<Option<OnDiskState>>>;
fn load_segment_timestamp(&self, segid: u64) -> impl Future<Output = Result<(i64, i64)>>;
fn flush_inode(&self, buf: &[u8], inode_state: &Option<OnDiskState>, flag: FlushInodeFlag) -> impl Future<Output = Result<Option<OnDiskState>>> + Send;
fn remove_inode(&self, inode_state: &Option<OnDiskState>) -> impl Future<Output = Result<()>>;
fn load_data_block(&self, segid: SegmentId, staging_off: usize, offset: usize, block_size: usize, buf: &mut [u8]) -> impl Future<Output = Result<()>> + Send;
fn load_range(&self, segid: SegmentId, s3_off: usize, buf: &mut [u8]) -> impl Future<Output = Result<()>> + Send;
fn new_segwr(&self, segid: SegmentId, hyper_file_config: &HyperFileMetaConfig) -> segment::Writer<Self> where Self: Sized;
fn dir_filename(&self) -> (&str, &str);
fn root_path(&self) -> &str;
fn config(&self) -> &StagingConfig;
fn unlink(&self) -> impl Future<Output = Result<()>>;
fn to_block_loader(&self) -> L;
fn interceptor(&mut self, i: impl StagingIntercept<Self> + 'static) where Self: Sized;
}
pub mod config;
pub mod s3;
#[cfg(not(feature = "blocking"))]
pub mod memory;
#[cfg(feature="bench")]
pub mod bench;