use crate::error::ServiceError; use bytes::{Buf, Bytes}; use h3::server::RequestStream; use h3_quinn::RecvStream; use hyper::body::{Body, Frame}; use std::{ pin::Pin, task::{Context, Poll}, }; pub struct H3RequestBody(pub RequestStream); impl Body for H3RequestBody { type Data = Bytes; type Error = ServiceError; fn poll_frame( mut self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll, Self::Error>>> { match self.0.poll_recv_data(cx) { Poll::Ready(Ok(Some(mut f))) => { Poll::Ready(Some(Ok(Frame::data(f.copy_to_bytes(f.remaining()))))) } Poll::Ready(Ok(None)) => Poll::Ready(None), Poll::Ready(Err(e)) => Poll::Ready(Some(Err(ServiceError::H3(e)))), Poll::Pending => Poll::Pending, } } }