Skip to content

Commit a8610ed

Browse files
authored
Merge pull request redis-rs#370 from mitsuhiko/connectioninfo-from-host-and-port
Create a connection from a host and port.
2 parents 6f7dba6 + 710744c commit a8610ed

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Support for Redis 6 auth ([#341](https://github.com/mitsuhiko/redis-rs/pull/341))
1515
* BUGFIX: Make aio::Connection Sync again ([#321](https://github.com/mitsuhiko/redis-rs/pull/321))
1616
* BUGFIX: Return UnexpectedEof if we try to decode at eof ([#322](https://github.com/mitsuhiko/redis-rs/pull/322))
17+
* Added support to create a connection from a (host, port) tuple ([#370](https://github.com/mitsuhiko/redis-rs/pull/370))
1718

1819
## [0.16.0](https://github.com/mitsuhiko/redis-rs/compare/0.15.1...0.16.0) - 2020-05-10
1920

src/client.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,13 @@ impl ConnectionLike for Client {
245245
}
246246
}
247247
}
248+
249+
#[cfg(test)]
250+
mod test {
251+
use super::*;
252+
253+
#[test]
254+
fn regression_293_parse_ipv6_with_interface() {
255+
assert!(Client::open(("fe80::cafe:beef%eno1", 6379)).is_ok());
256+
}
257+
}

src/connection.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,20 @@ impl<'a> IntoConnectionInfo for &'a str {
132132
}
133133
}
134134

135+
impl<T> IntoConnectionInfo for (T, u16)
136+
where
137+
T: Into<String>,
138+
{
139+
fn into_connection_info(self) -> RedisResult<ConnectionInfo> {
140+
Ok(ConnectionInfo {
141+
addr: Box::new(ConnectionAddr::Tcp(self.0.into(), self.1)),
142+
db: 0,
143+
username: None,
144+
passwd: None,
145+
})
146+
}
147+
}
148+
135149
impl IntoConnectionInfo for String {
136150
fn into_connection_info(self) -> RedisResult<ConnectionInfo> {
137151
match parse_redis_url(&self) {

0 commit comments

Comments
 (0)