make wisp-mux no longer eat data, fix wisp-mux stream read api

This commit is contained in:
Toshit Chawda 2024-11-03 12:47:05 -08:00
parent 0c8fe25089
commit f3a78a1715
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
4 changed files with 23 additions and 16 deletions

View file

@ -73,7 +73,7 @@ pin_project! {
/// Read side of a multiplexor stream that implements futures `Stream`.
pub struct MuxStreamIoStream {
#[pin]
pub(crate) rx: Pin<Box<dyn Stream<Item = Bytes> + Send>>,
pub(crate) rx: Pin<Box<dyn Stream<Item = Result<Bytes, WispError>> + Send>>,
pub(crate) is_closed: Arc<AtomicBool>,
pub(crate) close_reason: Arc<AtomicCloseReason>,
}
@ -98,7 +98,7 @@ impl MuxStreamIoStream {
impl Stream for MuxStreamIoStream {
type Item = Result<Bytes, std::io::Error>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
self.project().rx.poll_next(cx).map(|x| x.map(Ok))
self.project().rx.poll_next(cx).map_err(std::io::Error::other)
}
}