define DnsTcpStream supertrait for Connect

This commit is contained in:
Dirkjan Ochtman
2020-10-14 14:51:42 +02:00
committed by Benjamin Fry
parent ab46adcc09
commit c4d254b49b
4 changed files with 17 additions and 12 deletions

View File

@@ -11,7 +11,7 @@ use std::pin::Pin;
use async_trait::async_trait;
use futures_io::{AsyncRead, AsyncWrite};
use trust_dns_resolver::proto::tcp::Connect;
use trust_dns_resolver::proto::tcp::{Connect, DnsTcpStream};
use trust_dns_resolver::proto::udp::UdpSocket;
use crate::time::AsyncStdTime;
@@ -37,10 +37,12 @@ impl UdpSocket for AsyncStdUdpSocket {
pub struct AsyncStdTcpStream(async_std::net::TcpStream);
impl DnsTcpStream for AsyncStdTcpStream {
type Time = AsyncStdTime;
}
#[async_trait]
impl Connect for AsyncStdTcpStream {
type Time = AsyncStdTime;
async fn connect(addr: SocketAddr) -> io::Result<Self> {
let stream = async_std::net::TcpStream::connect(addr).await?;
stream.set_nodelay(true)?;