//! Synchronous combinator extensions to futures::TryStream use futures::{ future::{ready, Ready}, stream::{AndThen, TryStream, TryStreamExt}, }; use crate::Result; /// Synchronous combinators to augment futures::TryStreamExt. /// /// This interface is not necessarily complete; feel free to add as-needed. pub trait TryReadyExt where S: TryStream> + Send + ?Sized, Self: TryStream + Send + Sized, { fn ready_and_then(self, f: F) -> AndThen>, impl FnMut(S::Ok) -> Ready>> where F: Fn(S::Ok) -> Result; } impl TryReadyExt for S where S: TryStream> + Send + ?Sized, Self: TryStream + Send + Sized, { #[inline] fn ready_and_then(self, f: F) -> AndThen>, impl FnMut(S::Ok) -> Ready>> where F: Fn(S::Ok) -> Result, { self.and_then(move |t| ready(f(t))) } }