pub struct SocketAddrV4 {/* private fields */ }Expand description
An IPv4 socket address.
IPv4 socket addresses consist of anIPv4 address and a 16-bit port number, asstated inIETF RFC 793.
SeeSocketAddr for a type encompassing both IPv4 and IPv6 socket addresses.
§Portability
SocketAddrV4 is intended to be a portable representation of socket addresses and is likely notthe same as the internal socket address type used by the target operating system’s API. Like allrepr(Rust) structs, however, its exact layout remains undefined and should not be relied uponbetween builds.
§Textual representation
SocketAddrV4 provides aFromStr implementation.It accepts an IPv4 address in itstextual representation, followed by asingle:, followed by the port encoded as a decimal integer. Otherformats are not accepted.
§Examples
Implementations§
Source§implSocketAddrV4
implSocketAddrV4
Sourcepub fnparse_ascii(b: &[u8]) ->Result<SocketAddrV4,AddrParseError>
🔬This is a nightly-only experimental API. (addr_parse_ascii #101035)
pub fnparse_ascii(b: &[u8]) ->Result<SocketAddrV4,AddrParseError>
addr_parse_ascii #101035)Source§implSocketAddrV4
implSocketAddrV4
1.0.0 (const: 1.69.0) ·Sourcepub const fnnew(ip:Ipv4Addr, port:u16) ->SocketAddrV4
pub const fnnew(ip:Ipv4Addr, port:u16) ->SocketAddrV4
Creates a new socket address from anIPv4 address and a port number.
§Examples
1.0.0 (const: 1.69.0) ·Sourcepub const fnip(&self) -> &Ipv4Addr
pub const fnip(&self) -> &Ipv4Addr
Returns the IP address associated with this socket address.
§Examples
1.9.0 (const: 1.87.0) ·Sourcepub const fnset_ip(&mut self, new_ip:Ipv4Addr)
pub const fnset_ip(&mut self, new_ip:Ipv4Addr)
Changes the IP address associated with this socket address.
§Examples
Trait Implementations§
1.0.0 ·Source§implClone forSocketAddrV4
implClone forSocketAddrV4
Source§fnclone(&self) ->SocketAddrV4
fnclone(&self) ->SocketAddrV4
1.0.0 ·Source§fnclone_from(&mut self, source: &Self)
fnclone_from(&mut self, source: &Self)
source.Read more1.0.0 ·Source§implDebug forSocketAddrV4
implDebug forSocketAddrV4
1.0.0 ·Source§implDisplay forSocketAddrV4
implDisplay forSocketAddrV4
1.16.0 (const:unstable) ·Source§implFrom<SocketAddrV4> forSocketAddr
implFrom<SocketAddrV4> forSocketAddr
Source§fnfrom(sock4:SocketAddrV4) ->SocketAddr
fnfrom(sock4:SocketAddrV4) ->SocketAddr
Converts aSocketAddrV4 into aSocketAddr::V4.
1.5.0 ·Source§implFromStr forSocketAddrV4
implFromStr forSocketAddrV4
Source§typeErr =AddrParseError
typeErr =AddrParseError
Source§fnfrom_str(s: &str) ->Result<SocketAddrV4,AddrParseError>
fnfrom_str(s: &str) ->Result<SocketAddrV4,AddrParseError>
s to return a value of this type.Read more1.0.0 ·Source§implHash forSocketAddrV4
implHash forSocketAddrV4
1.0.0 ·Source§implOrd forSocketAddrV4
implOrd forSocketAddrV4
1.0.0 ·Source§implPartialEq forSocketAddrV4
implPartialEq forSocketAddrV4
1.0.0 ·Source§implPartialOrd forSocketAddrV4
implPartialOrd forSocketAddrV4
1.0.0 ·Source§implToSocketAddrs forSocketAddrV4
implToSocketAddrs forSocketAddrV4
Source§typeIter =IntoIter<SocketAddr>
typeIter =IntoIter<SocketAddr>
Source§fnto_socket_addrs(&self) ->Result<IntoIter<SocketAddr>>
fnto_socket_addrs(&self) ->Result<IntoIter<SocketAddr>>
SocketAddrs.Read more