File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,39 +35,8 @@ impl<S> HyperStream<S> {
3535 }
3636}
3737
38- impl < S : AsyncRead + AsyncWrite + Unpin > AsyncRead for HyperStream < S > {
39- fn poll_read (
40- self : Pin < & mut Self > ,
41- cx : & mut Context < ' _ > ,
42- buf : & mut tokio:: io:: ReadBuf < ' _ > ,
43- ) -> Poll < std:: io:: Result < ( ) > > {
44- // SAFETY: HyperStream is Unpin if S is Unpin
45- let this = unsafe { self . get_unchecked_mut ( ) } ;
46- Pin :: new ( & mut this. inner ) . poll_read ( cx, buf)
47- }
48- }
49-
50- impl < S : AsyncRead + AsyncWrite + Unpin > AsyncWrite for HyperStream < S > {
51- fn poll_write (
52- self : Pin < & mut Self > ,
53- cx : & mut Context < ' _ > ,
54- buf : & [ u8 ] ,
55- ) -> Poll < std:: io:: Result < usize > > {
56- let this = unsafe { self . get_unchecked_mut ( ) } ;
57- Pin :: new ( & mut this. inner ) . poll_write ( cx, buf)
58- }
59-
60- fn poll_flush ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < std:: io:: Result < ( ) > > {
61- let this = unsafe { self . get_unchecked_mut ( ) } ;
62- Pin :: new ( & mut this. inner ) . poll_flush ( cx)
63- }
64-
65- fn poll_shutdown ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < std:: io:: Result < ( ) > > {
66- let this = unsafe { self . get_unchecked_mut ( ) } ;
67- Pin :: new ( & mut this. inner ) . poll_shutdown ( cx)
68- }
69- }
70-
38+ // Note: HyperStream only implements hyper's Read/Write traits, not tokio's AsyncRead/AsyncWrite
39+ // TokioIo already bridges between tokio and hyper traits internally
7140impl < S : AsyncRead + AsyncWrite + Unpin > Read for HyperStream < S > {
7241 fn poll_read (
7342 self : Pin < & mut Self > ,
Original file line number Diff line number Diff line change 8484
8585 fn call ( & mut self , req : hyper:: Request < hyper:: body:: Incoming > ) -> Self :: Future {
8686 // Convert Incoming body to tonic's BoxBody
87+ // Need to map the error type from io::Error to tonic::Status
8788 let ( parts, body) = req. into_parts ( ) ;
89+ let body = body. map_err ( |e| tonic:: Status :: internal ( format ! ( "body error: {}" , e) ) ) ;
8890 let body = tonic:: body:: BoxBody :: new ( body) ;
8991 let req = hyper:: Request :: from_parts ( parts, body) ;
9092 self . inner . call ( req)
You can’t perform that action at this time.
0 commit comments