Skip to content

Commit

Permalink
Impl reconnect for boxed reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
rustworthy committed Aug 3, 2024
1 parent aee5ad2 commit a1cfc1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/proto/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub(crate) enum HeartbeatStatus {

impl Client {
/// Create new [`Client`] and connect to a Faktory server with a non-standard stream.
///
///
/// Iternally, the `stream` will be buffered. In case you've got a `stream` that is _already_
/// buffered (and so it is `AsyncBufRead`), you will want to use [`Client::connect_with_buffered`]
/// in order to avoid buffering the stream twice.
Expand All @@ -199,7 +199,7 @@ impl Client {
}

/// Create new [`Client`] and connect to a Faktory server with a non-standard buffered stream.
///
///
/// In case you've got a `stream` that is _not_ buffered just yet, you may want to use [`Client::connect_with`]
/// that will do this buffering for you.
pub async fn connect_with_buffered<S>(stream: S, pwd: Option<String>) -> Result<Client, Error>
Expand Down
10 changes: 10 additions & 0 deletions src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ pub trait Reconnect {
async fn reconnect(&mut self) -> io::Result<BoxedConnection>;
}

#[async_trait::async_trait]
impl<S> Reconnect for Box<S>
where
S: Reconnect + Send,
{
async fn reconnect(&mut self) -> io::Result<BoxedConnection> {
(**self).reconnect().await
}

Check warning on line 48 in src/proto/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/proto/mod.rs#L46-L48

Added lines #L46 - L48 were not covered by tests
}

#[async_trait::async_trait]
impl Reconnect for TokioStream {
async fn reconnect(&mut self) -> io::Result<BoxedConnection> {
Expand Down

0 comments on commit a1cfc1d

Please sign in to comment.