Skip to content

Commit

Permalink
chore(client/conn): SendRequest conversion glue
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cratelyn committed Nov 28, 2024
1 parent 9655084 commit 701ddf2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/client/conn/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,14 @@ impl<B> fmt::Debug for SendRequest<B> {
}
}

/// A [`SendRequest<B>`] can be constructed from its legacy counterpart.
#[cfg_attr(feature = "deprecated", allow(deprecated))]
impl<B> From<super::SendRequest<B>> for SendRequest<B> {
fn from(super::SendRequest { dispatch }: super::SendRequest<B>) -> Self {
SendRequest { dispatch }
}
}

// ===== impl Connection

impl<T, B> fmt::Debug for Connection<T, B>
Expand Down
10 changes: 10 additions & 0 deletions src/client/conn/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ impl<B> fmt::Debug for SendRequest<B> {
}
}

/// A [`SendRequest<B>`] can be constructed from its legacy counterpart.
#[cfg_attr(feature = "deprecated", allow(deprecated))]
impl<B> From<super::SendRequest<B>> for SendRequest<B> {
fn from(super::SendRequest { dispatch }: super::SendRequest<B>) -> Self {
Self {
dispatch: dispatch.unbound(),
}
}
}

// ===== impl Connection

impl<T, B> Connection<T, B>
Expand Down

0 comments on commit 701ddf2

Please sign in to comment.