pub struct CappedPeerAddr(pub SocketAddr);Expand description
Peer socket address for a connection accepted through a
MaxConnListener over a TcpListener.
axum’s built-in connect-info impl for SocketAddr is bound to the concrete
TcpListener, so a capped site cannot ask for ConnectInfo<SocketAddr>
directly (the cap wraps the listener). It asks for
ConnectInfo<CappedPeerAddr> instead; this type derefs and displays as the
wrapped SocketAddr, so per-IP logic reads unchanged.
Tuple Fields§
§0: SocketAddrMethods from Deref<Target = SocketAddr>§
1.7.0 · Sourcepub fn ip(&self) -> IpAddr
pub fn ip(&self) -> IpAddr
Returns the IP address associated with this socket address.
§Examples
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
assert_eq!(socket.ip(), IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));1.0.0 · Sourcepub fn port(&self) -> u16
pub fn port(&self) -> u16
Returns the port number associated with this socket address.
§Examples
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
assert_eq!(socket.port(), 8080);1.16.0 · Sourcepub fn is_ipv4(&self) -> bool
pub fn is_ipv4(&self) -> bool
Returns true if the IP address in this SocketAddr is an
IPv4 address, and false otherwise.
§Examples
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
assert_eq!(socket.is_ipv4(), true);
assert_eq!(socket.is_ipv6(), false);1.16.0 · Sourcepub fn is_ipv6(&self) -> bool
pub fn is_ipv6(&self) -> bool
Returns true if the IP address in this SocketAddr is an
IPv6 address, and false otherwise.
§Examples
use std::net::{IpAddr, Ipv6Addr, SocketAddr};
let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 65535, 0, 1)), 8080);
assert_eq!(socket.is_ipv4(), false);
assert_eq!(socket.is_ipv6(), true);Trait Implementations§
Source§impl Clone for CappedPeerAddr
impl Clone for CappedPeerAddr
Source§fn clone(&self) -> CappedPeerAddr
fn clone(&self) -> CappedPeerAddr
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Connected<IncomingStream<'_, MaxConnListener<TcpListener>>> for CappedPeerAddr
impl Connected<IncomingStream<'_, MaxConnListener<TcpListener>>> for CappedPeerAddr
Source§fn connect_info(
stream: IncomingStream<'_, MaxConnListener<TcpListener>>,
) -> Self
fn connect_info( stream: IncomingStream<'_, MaxConnListener<TcpListener>>, ) -> Self
Create type holding information about the connection.
impl Copy for CappedPeerAddr
Source§impl Debug for CappedPeerAddr
impl Debug for CappedPeerAddr
Source§impl Deref for CappedPeerAddr
impl Deref for CappedPeerAddr
Auto Trait Implementations§
impl Freeze for CappedPeerAddr
impl RefUnwindSafe for CappedPeerAddr
impl Send for CappedPeerAddr
impl Sync for CappedPeerAddr
impl Unpin for CappedPeerAddr
impl UnsafeUnpin for CappedPeerAddr
impl UnwindSafe for CappedPeerAddr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more