use std::pin::Pin;
use bytes::Bytes;
use futures::{stream::BoxStream, Future};
use libipld::Cid;
use tokio::io::AsyncRead;
use super::{IpldStore, SeekableReader, StoreResult};
pub trait Layout {
fn organize<'a>(
&self,
stream: BoxStream<'a, StoreResult<Bytes>>,
store: impl IpldStore + Send + Sync + 'a,
) -> impl Future<Output = StoreResult<BoxStream<'a, StoreResult<Cid>>>> + Send;
fn retrieve<'a>(
&self,
cid: &Cid,
store: impl IpldStore + Send + Sync + 'a,
) -> impl Future<Output = StoreResult<Pin<Box<dyn AsyncRead + Send + Sync + 'a>>>> + Send;
}
pub trait LayoutSeekable: Layout {
fn retrieve_seekable<'a>(
&self,
cid: &'a Cid,
store: impl IpldStore + Send + Sync + 'a,
) -> impl Future<Output = StoreResult<Pin<Box<dyn SeekableReader + Send + 'a>>>> + Send;
}