pub fn fold_blocks<F, T, Fut>(self, init: T, f: F) -> impl Future<Item=(ClientHandle, T), Error=Error>
        where
            F: Fn(T, Block) -> Fut + Send + 'static,
            Fut: IntoFuture<Item = T, Error = Error> + Send + 'static,
            Fut::Future: Send,
            T: Send + 'static,
    {
        let timeout = try_opt!(self.client.context.options.get()).query_timeout;
        let context = self.client.context.clone();
        let pool = self.client.pool.clone();

        let acc = (None, init);

        let future = self.fold_packets(acc, move |(h, acc), packet| match packet {
            Packet::Block(b) => {
                if b.is_empty() {
                    Either::Right(future::ok((h, acc)))
                } else {
                    Either::Left(f(acc, b).into_future().map(move |a| (h, a)))
                }
            }
            Packet::Eof(inner) => Either::Right(future::ok((
                Some(ClientHandle {
                    inner: Some(inner),
                    context: context.clone(),
                    pool: pool.clone(),
                }),
                acc,
            ))),
            Packet::ProfileInfo(_) | Packet::Progress(_) => Either::Right(future::ok((h, acc))),
            Packet::Exception(exception) => Either::Right(future::err(Error::Server(exception))),
            _ => Either::Right(future::err(Error::Driver(DriverError::UnexpectedPacket))),
        });

        let fut = if let Some(timeout) = timeout {
            Either::Left(
                future
                    .map(|(c, t)| (c.unwrap(), t))
                    .timeout(timeout)
                    .map_err(move |err| err.into()),
            )
        } else {
            Either::Right(future.map(|(c, t)| (c.unwrap(), t)))
        };

        Either::Right(fut)
    }
/// Method that applies a function to each block, producing a single, final value.
Method that applies a function to each block, producing a single, final value.
Method that applies a function to each block producing a single final value .
pub fn fold_blocks<F, T, Fut>(self, init: T, f: F) -> impl Future<Item=(ClientHandle, T), Error=Error>
        where
            F: Fn(T, Block) -> Fut + Send + 'static,
            Fut: IntoFuture<Item = T, Error = Error> + Send + 'static,
            Fut::Future: Send,
            T: Send + 'static,
    {
        let timeout = try_opt!(self.client.context.options.get()).query_timeout;
        let context = self.client.context.clone();
        let pool = self.client.pool.clone();
        let acc = (None, init);
        let future = self.fold_packets(acc, move |(h, acc), packet| match packet {
            Packet::Block(b) => {
                if b.is_empty() {
                    Either::Right(future::ok((h, acc)))
                } else {
                    Either::Left(f(acc, b).into_future().map(move |a| (h, a)))
                }
            }
            Packet::Eof(inner) => Either::Right(future::ok((
                Some(ClientHandle {
                    inner: Some(inner),
                    context: context.clone(),
                    pool: pool.clone(),
                }),
                acc,
            ))),
            Packet::ProfileInfo(_) | Packet::Progress(_) => Either::Right(future::ok((h, acc))),
            Packet::Exception(exception) => Either::Right(future::err(Error::Server(exception))),
            _ => Either::Right(future::err(Error::Driver(DriverError::UnexpectedPacket))),
        });
        let fut = if let Some(timeout) = timeout {
            Either::Left(
                future
                    .map(|(c, t)| (c.unwrap(), t))
                    .timeout(timeout)
                    .map_err(move |err| err.into()),
            )
        } else {
            Either::Right(future.map(|(c, t)| (c.unwrap(), t)))
        };
        Either::Right(fut)
    }
pub fn fold_blocks < F , T , Fut > ( self , init : T , f : F ) -> impl Future < Item = ( ClientHandle , T ) , Error = Error > where F : Fn ( T , Block ) -> Fut + Send + ' static , Fut : IntoFuture < Item = T , Error = Error > + Send + ' static , Fut :: Future : Send , T : Send + ' static , { let timeout = try_opt ! ( self client context options get ( ) ) . query_timeout ; let context = self . client . context . clone ( ) ; let pool = self . client . pool . clone ( ) ; let acc = ( None , init ) ; let future = self . fold_packets ( acc , move | ( h , acc ) , packet | match packet { Packet :: Block ( b ) => { if b . is_empty ( ) { Either :: Right ( future :: ok ( ( h , acc ) ) ) } else { Either :: Left ( f ( acc , b ) . into_future ( ) . map ( move | a | ( h , a ) ) ) } } Packet :: Eof ( inner ) => Either :: Right ( future :: ok ( ( Some ( ClientHandle { inner : Some ( inner ) , context : context . clone ( ) , pool : pool . clone ( ) , } ) , acc , ) ) ) , Packet :: ProfileInfo ( _ ) | Packet :: Progress ( _ ) => Either :: Right ( future :: ok ( ( h , acc ) ) ) , Packet :: Exception ( exception ) => Either :: Right ( future :: err ( Error :: Server ( exception ) ) ) , _ => Either :: Right ( future :: err ( Error :: Driver ( DriverError :: UnexpectedPacket ) ) ) , } ) ; let fut = if let Some ( timeout ) = timeout { Either :: Left ( future . map ( | ( c , t ) | ( c . unwrap ( ) , t ) ) . timeout ( timeout ) . map_err ( move | err | err . into ( ) ) , ) } else { Either :: Right ( future . map ( | ( c , t ) | ( c . unwrap ( ) , t ) ) ) } ; Either :: Right ( fut ) }
Method that applies a function to each block, producing a single, final value.
Method that applies a function to each block producing a single final value .
self
init
T
f
F
self
init
T
f
F