Skip to content

Commit 5ef4385

Browse files
committed
Move body impl, use box dyn error type
1 parent 25f9213 commit 5ef4385

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

opentelemetry-http/src/lib.rs

+26-26
Original file line numberDiff line numberDiff line change
@@ -115,32 +115,6 @@ pub mod hyper {
115115
use std::time::Duration;
116116
use tokio::time;
117117

118-
pub struct Body(Full<Bytes>);
119-
120-
impl HttpBody for Body {
121-
type Data = Bytes;
122-
type Error = Infallible;
123-
124-
#[inline]
125-
fn poll_frame(
126-
self: Pin<&mut Self>,
127-
cx: &mut task::Context<'_>,
128-
) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
129-
let inner_body = unsafe { self.map_unchecked_mut(|b| &mut b.0) };
130-
inner_body.poll_frame(cx)
131-
}
132-
133-
#[inline]
134-
fn is_end_stream(&self) -> bool {
135-
self.0.is_end_stream()
136-
}
137-
138-
#[inline]
139-
fn size_hint(&self) -> hyper::body::SizeHint {
140-
self.0.size_hint()
141-
}
142-
}
143-
144118
#[derive(Debug, Clone)]
145119
pub struct HyperClient<C> {
146120
inner: Client<C, Body>,
@@ -194,6 +168,32 @@ pub mod hyper {
194168
Ok(http_response.error_for_status()?)
195169
}
196170
}
171+
172+
pub struct Body(Full<Bytes>);
173+
174+
impl HttpBody for Body {
175+
type Data = Bytes;
176+
type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
177+
178+
#[inline]
179+
fn poll_frame(
180+
self: Pin<&mut Self>,
181+
cx: &mut task::Context<'_>,
182+
) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
183+
let inner_body = unsafe { self.map_unchecked_mut(|b| &mut b.0) };
184+
inner_body.poll_frame(cx)
185+
}
186+
187+
#[inline]
188+
fn is_end_stream(&self) -> bool {
189+
self.0.is_end_stream()
190+
}
191+
192+
#[inline]
193+
fn size_hint(&self) -> hyper::body::SizeHint {
194+
self.0.size_hint()
195+
}
196+
}
197197
}
198198

199199
/// Methods to make working with responses from the [`HttpClient`] trait easier.

0 commit comments

Comments
 (0)