Skip to main content

fast_pull/base/
puller.rs

1use crate::ProgressEntry;
2use bytes::Bytes;
3use core::time::Duration;
4use futures::TryStream;
5
6pub trait PullStream<E>:
7    TryStream<Ok = Bytes, Error = (E, Option<Duration>)> + Send + Unpin
8{
9}
10impl<E, T> PullStream<E> for T where
11    T: TryStream<Ok = Bytes, Error = (E, Option<Duration>)> + Send + Unpin
12{
13}
14pub type PullResult<T, E> = Result<T, (E, Option<Duration>)>;
15
16pub trait Puller: Send + Sync + Clone + 'static {
17    type Error: Send + Unpin + 'static;
18    fn pull(
19        &mut self,
20        range: Option<&ProgressEntry>,
21    ) -> impl Future<Output = PullResult<impl PullStream<Self::Error>, Self::Error>> + Send;
22}