elefant_tools/storage/
table_data.rs1use crate::storage::data_format::DataFormat;
2use crate::Result;
3use std::future::Future;
4
5pub trait TableDataReader: Send {
6 fn read_chunk(&mut self) -> impl Future<Output = Result<Option<&[u8]>>> + '_;
7}
8
9pub struct TableData<R: TableDataReader, C: AsyncCleanup> {
13 pub data: R,
14 pub data_format: DataFormat,
15 pub cleanup: C,
16}
17
18pub trait AsyncCleanup: Send {
19 fn cleanup(self) -> impl Future<Output = Result<()>>;
20}
21
22impl AsyncCleanup for () {
23 async fn cleanup(self) -> Result<()> {
24 Ok(())
25 }
26}
27
28impl<R: TableDataReader, C: AsyncCleanup> AsyncCleanup for TableData<R, C> {
29 fn cleanup(self) -> impl Future<Output = Result<()>> {
30 self.cleanup.cleanup()
31 }
32}