diff --git a/src/session/async_session.rs b/src/session/async_session.rs index ef1ed1f..6223e95 100644 --- a/src/session/async_session.rs +++ b/src/session/async_session.rs @@ -80,6 +80,29 @@ impl
Session
{
self.stream.expect(needle).await
}
+ /// Expect waits until a pattern is matched. This continuously reads all the
+ /// available output, consumes it from the buffer and try to match on it
+ /// until a match is found.
+ ///
+ /// Typically, you'd want to use `expect_eager` over `expect` when the
+ /// command under test produces too much output to be processed lazily.
+ ///
+ /// If the method returns [Ok] it is guaranteed that at least 1 match was found.
+ ///
+ /// ```
+ /// # futures_lite::future::block_on(async {
+ /// let mut p = expectrl::spawn("echo 123").unwrap();
+ /// let m = p.expect_eager(expectrl::Regex("\\d+")).await.unwrap();
+ /// assert_eq!(m.first(), b"123");
+ /// # })
+ /// ```
+ ///
+ /// It return an error if timeout is reached.
+ /// You can specify a timeout value by [Session::set_expect_timeout] method.
+ pub async fn expect_eager Session {
}
}
+ /// Expect waits until a pattern is matched. This continuously reads all the
+ /// available output, consumes it from the buffer and try to match on it
+ /// until a match is found.
+ ///
+ /// Typically, you'd want to use `expect_eager` over `expect` when the
+ /// command under test produces too much output to be processed lazily.
+ ///
+ /// If the method returns [Ok] it is guaranteed that at least 1 match was found.
+ ///
+ /// ```
+ /// let mut p = expectrl::spawn("echo 123").unwrap();
+ /// let m = p.expect_eager(expectrl::Regex("\\d+")).unwrap();
+ /// assert_eq!(m.first(), b"123");
+ /// ```
+ ///
+ /// It returns an error if timeout is reached.
+ /// You can specify a timeout value by [Session::set_expect_timeout] method.
+ pub fn expect_eager {
}
}
+ async fn expect_eager