Add test infrastructure to work directly with frames (#56)

This adds a `Codec` based testing API. This is a bit less annoying than writing
at the raw H2 wire protocol level...
This commit is contained in:
Carl Lerche
2017-09-06 14:18:37 -07:00
committed by GitHub
parent 711086c184
commit cd76aca6d4
17 changed files with 601 additions and 222 deletions

View File

@@ -0,0 +1,32 @@
use futures::{Future, Poll};
use std::fmt;
pub trait FutureExt: Future {
fn unwrap(self) -> Unwrap<Self>
where Self: Sized,
Self::Error: fmt::Debug,
{
Unwrap { inner: self }
}
}
pub struct Unwrap<T> {
inner: T,
}
impl<T: Future> FutureExt for T {
}
impl<T> Future for Unwrap<T>
where T: Future,
T::Item: fmt::Debug,
T::Error: fmt::Debug,
{
type Item = T::Item;
type Error = ();
fn poll(&mut self) -> Poll<T::Item, ()> {
Ok(self.inner.poll().unwrap())
}
}