Skip to content

Commit de82efb

Browse files
committed
chore(client/conn): SendRequest conversion glue
users of the `backports` feature that are attempting to migrate from 0.14 to 1.0 may need to convert from a legacy `SendRequest` (returned by some of the connector builders) to an instance of the new protocol specific `conn::http2::SendRequest<B>` or `conn::http1::SendRequest<B>` senders. this adds `From<T>` implementation to the type provided by the `backports` feature, to help facilitate incremental migration. Signed-off-by: katelyn martin <me+cratelyn@katelyn.world>
1 parent a24f0c0 commit de82efb

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎src/client/conn/http1.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,14 @@ impl<B> fmt::Debug for SendRequest<B> {
250250
}
251251
}
252252

253+
/// A [`SendRequest<B>`] can be constructed from its legacy counterpart.
254+
#[cfg_attr(feature = "deprecated", allow(deprecated))]
255+
impl<B> From<super::SendRequest<B>> for SendRequest<B> {
256+
fn from(super::SendRequest { dispatch }: super::SendRequest<B>) -> Self {
257+
SendRequest { dispatch }
258+
}
259+
}
260+
253261
// ===== impl Connection
254262

255263
impl<T, B> fmt::Debug for Connection<T, B>

‎src/client/conn/http2.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,16 @@ impl<B> fmt::Debug for SendRequest<B> {
188188
}
189189
}
190190

191+
/// A [`SendRequest<B>`] can be constructed from its legacy counterpart.
192+
#[cfg_attr(feature = "deprecated", allow(deprecated))]
193+
impl<B> From<super::SendRequest<B>> for SendRequest<B> {
194+
fn from(super::SendRequest { dispatch }: super::SendRequest<B>) -> Self {
195+
Self {
196+
dispatch: dispatch.unbound(),
197+
}
198+
}
199+
}
200+
191201
// ===== impl Connection
192202

193203
impl<T, B> Connection<T, B>

0 commit comments

Comments
 (0)