-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(viz): add custom Listener Trait back
- Loading branch information
Showing
14 changed files
with
91 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use std::{future::Future, io::Result}; | ||
|
||
use tokio::io::{AsyncRead, AsyncWrite}; | ||
|
||
/// A trait for a listener: `TcpListener` and `UnixListener`. | ||
pub trait Listener { | ||
/// The stream's type of this listener. | ||
type Io: AsyncRead + AsyncWrite; | ||
/// The socket address type of this listener. | ||
type Addr; | ||
|
||
/// Accepts a new incoming connection from this listener. | ||
fn accept(&self) -> impl Future<Output = Result<(Self::Io, Self::Addr)>> + Send; | ||
|
||
/// Returns the local address that this listener is bound to. | ||
fn local_addr(&self) -> Result<Self::Addr>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::{future::Future, io::Result, net::SocketAddr}; | ||
|
||
use tokio::net::{TcpListener, TcpStream}; | ||
|
||
impl super::Listener for TcpListener { | ||
type Io = TcpStream; | ||
type Addr = SocketAddr; | ||
|
||
fn accept(&self) -> impl Future<Output = Result<(Self::Io, Self::Addr)>> + Send { | ||
TcpListener::accept(self) | ||
} | ||
|
||
fn local_addr(&self) -> Result<Self::Addr> { | ||
TcpListener::local_addr(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::{future::Future, io::Result}; | ||
|
||
use tokio::net::{unix::SocketAddr, UnixListener, UnixStream}; | ||
|
||
impl super::Listener for UnixListener { | ||
type Io = UnixStream; | ||
type Addr = SocketAddr; | ||
|
||
fn accept(&self) -> impl Future<Output = Result<(Self::Io, Self::Addr)>> + Send { | ||
UnixListener::accept(self) | ||
} | ||
|
||
fn local_addr(&self) -> Result<Self::Addr> { | ||
UnixListener::local_addr(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters