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: PullerError;
18 fn pull(
19 &mut self,
20 range: Option<&ProgressEntry>,
21 ) -> impl Future<Output = PullResult<impl PullStream<Self::Error>, Self::Error>> + Send;
22}
23
24pub trait PullerError: Send + Unpin + 'static {
25 fn is_irrecoverable(&self) -> bool {
26 false
27 }
28}