Skip to content

Commit 0e8667f

Browse files
committed
WIP: Hyper 1.0 migration - fix net.rs and rpc body conversions
- Removed incorrect AsyncRead/AsyncWrite from HyperStream - Added body error mapping for tonic::BoxBody - Still working on TonicServiceWrapper trait bounds - 43 errors remaining
1 parent 3b001c2 commit 0e8667f

2 files changed

Lines changed: 4 additions & 33 deletions

File tree

libsql-server/src/net.rs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff 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
7140
impl<S: AsyncRead + AsyncWrite + Unpin> Read for HyperStream<S> {
7241
fn poll_read(
7342
self: Pin<&mut Self>,

libsql-server/src/rpc/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ where
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)

0 commit comments

Comments
 (0)