Skip to content

Commit

Permalink
feat: Provide a new_async_std function
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Westerlind committed May 31, 2021
1 parent 06962cb commit c3716d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/aio.rs
Expand Up @@ -279,7 +279,7 @@ where
C: Unpin + AsyncRead + AsyncWrite + Send,
{
/// Constructs a new `Connection` out of a `AsyncRead + AsyncWrite` object
/// and a `ConnectionInfo`
/// and a `RedisConnectionInfo`
pub async fn new(connection_info: &RedisConnectionInfo, con: C) -> RedisResult<Self> {
let mut rv = Connection {
con,
Expand Down Expand Up @@ -373,6 +373,19 @@ where
}
}

#[cfg(feature = "async-std-comp")]
#[cfg_attr(docsrs, doc(cfg(feature = "async-std-comp")))]
impl<C> Connection<async_std::AsyncStdWrapped<C>>
where
C: Unpin + ::async_std::io::Read + ::async_std::io::Write + Send,
{
/// Constructs a new `Connection` out of a `async_std::io::AsyncRead + async_std::io::AsyncWrite` object
/// and a `RedisConnectionInfo`
pub async fn new_async_std(connection_info: &RedisConnectionInfo, con: C) -> RedisResult<Self> {
Connection::new(connection_info, async_std::AsyncStdWrapped::new(con)).await
}
}

pub(crate) async fn connect<C>(connection_info: &ConnectionInfo) -> RedisResult<Connection<C>>
where
C: Unpin + RedisRuntime + AsyncRead + AsyncWrite + Send,
Expand Down
2 changes: 1 addition & 1 deletion src/aio/async_std.rs
Expand Up @@ -26,7 +26,7 @@ pin_project_lite::pin_project! {
}

impl<T> AsyncStdWrapped<T> {
fn new(inner: T) -> Self {
pub(super) fn new(inner: T) -> Self {
Self { inner }
}
}
Expand Down

0 comments on commit c3716d1

Please sign in to comment.