Files
reth/crates/net/common/src/stream.rs
2023-01-09 10:43:46 +02:00

14 lines
360 B
Rust

use std::net::SocketAddr;
use tokio::net::TcpStream;
/// This trait is for instrumenting a TCPStream with a socket addr
pub trait HasRemoteAddr {
/// Maybe returns a [`SocketAddr`]
fn remote_addr(&self) -> Option<SocketAddr>;
}
impl HasRemoteAddr for TcpStream {
fn remote_addr(&self) -> Option<SocketAddr> {
self.peer_addr().ok()
}
}