pub struct SocketAddress {
pub ip_addr: IpAddr,
pub port: u16,
}Expand description
An IpAddr with an associated port (u16)
Fields§
§ip_addr: IpAddr§port: u16Implementations§
Source§impl SocketAddress
impl SocketAddress
Sourcepub const fn new(ip_addr: IpAddr, port: u16) -> Self
pub const fn new(ip_addr: IpAddr, port: u16) -> Self
creates a new SocketAddress
Sourcepub const fn local_ipv4(port: u16) -> Self
pub const fn local_ipv4(port: u16) -> Self
creates a new local ipv4 SocketAddress for the given port
§Example
use rama_net::address::SocketAddress;
let addr = SocketAddress::local_ipv4(8080);
assert_eq!("127.0.0.1:8080", addr.to_string());Sourcepub const fn local_ipv6(port: u16) -> Self
pub const fn local_ipv6(port: u16) -> Self
creates a new local ipv6 SocketAddress for the given port.
§Example
use rama_net::address::SocketAddress;
let addr = SocketAddress::local_ipv6(8080);
assert_eq!("[::1]:8080", addr.to_string());Sourcepub const fn default_ipv4(port: u16) -> Self
pub const fn default_ipv4(port: u16) -> Self
creates a new default ipv4 SocketAddress for the given port
§Example
use rama_net::address::SocketAddress;
let addr = SocketAddress::default_ipv4(8080);
assert_eq!("0.0.0.0:8080", addr.to_string());Sourcepub const fn default_ipv6(port: u16) -> Self
pub const fn default_ipv6(port: u16) -> Self
creates a new default ipv6 SocketAddress for the given port.
§Example
use rama_net::address::SocketAddress;
let addr = SocketAddress::default_ipv6(8080);
assert_eq!("[::]:8080", addr.to_string());Sourcepub fn has_private_ip_addr(self) -> bool
pub fn has_private_ip_addr(self) -> bool
Returns true when the SocketAddress’s ip address
belongs to a range that should be treated as
private instead of a normal public-Internet destination.
Sourcepub fn from_std(addr: SocketAddr) -> Self
pub fn from_std(addr: SocketAddr) -> Self
Create a SocketAddress from the std SocketAddr version.
Sourcepub fn into_std(self) -> SocketAddr
pub fn into_std(self) -> SocketAddr
Turn the SocketAddress into the std SocketAddr version.
Sourcepub const fn broadcast_ipv4(port: u16) -> Self
pub const fn broadcast_ipv4(port: u16) -> Self
creates a new broadcast ipv4 SocketAddress for the given port
§Example
use rama_net::address::SocketAddress;
let addr = SocketAddress::broadcast_ipv4(8080);
assert_eq!("255.255.255.255:8080", addr.to_string());Sourcepub fn with_ip(self, ip_addr: IpAddr) -> Self
pub fn with_ip(self, ip_addr: IpAddr) -> Self
Set IpAddr as the ip of SocketAddress
Sourcepub fn set_ip(&mut self, ip_addr: IpAddr) -> &mut Self
pub fn set_ip(&mut self, ip_addr: IpAddr) -> &mut Self
Set IpAddr as the ip of SocketAddress
Sourcepub fn with_ipv4(self, ip_addr: Ipv4Addr) -> Self
pub fn with_ipv4(self, ip_addr: Ipv4Addr) -> Self
Set Ipv4Addr as the ip of SocketAddress
Sourcepub fn set_ipv4(&mut self, ip_addr: Ipv4Addr) -> &mut Self
pub fn set_ipv4(&mut self, ip_addr: Ipv4Addr) -> &mut Self
Set Ipv4Addr as the ip of SocketAddress
Sourcepub fn with_ipv6(self, ip_addr: Ipv6Addr) -> Self
pub fn with_ipv6(self, ip_addr: Ipv6Addr) -> Self
Set Ipv6Addr as the ip of SocketAddress
Sourcepub fn set_ipv6(&mut self, ip_addr: Ipv6Addr) -> &mut Self
pub fn set_ipv6(&mut self, ip_addr: Ipv6Addr) -> &mut Self
Set Ipv6Addr as the ip of SocketAddress
Sourcepub fn with_port(self, port: u16) -> Self
pub fn with_port(self, port: u16) -> Self
Set port (u16) of SocketAddress
Sourcepub fn set_port(&mut self, port: u16) -> &mut Self
pub fn set_port(&mut self, port: u16) -> &mut Self
Set port (u16) of SocketAddress
Trait Implementations§
Source§impl Clone for SocketAddress
impl Clone for SocketAddress
Source§fn clone(&self) -> SocketAddress
fn clone(&self) -> SocketAddress
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SocketAddress
Source§impl Debug for SocketAddress
impl Debug for SocketAddress
Source§impl<'de> Deserialize<'de> for SocketAddress
impl<'de> Deserialize<'de> for SocketAddress
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Display for SocketAddress
impl Display for SocketAddress
impl Eq for SocketAddress
Source§impl From<&SocketAddr> for SocketAddress
impl From<&SocketAddr> for SocketAddress
Source§fn from(addr: &SocketAddr) -> Self
fn from(addr: &SocketAddr) -> Self
Source§impl From<&SocketAddress> for HostWithPort
impl From<&SocketAddress> for HostWithPort
Source§fn from(addr: &SocketAddress) -> Self
fn from(addr: &SocketAddress) -> Self
Source§impl From<&SocketAddress> for HostWithOptPort
impl From<&SocketAddress> for HostWithOptPort
Source§fn from(addr: &SocketAddress) -> Self
fn from(addr: &SocketAddress) -> Self
Source§impl From<&SocketAddress> for Authority
impl From<&SocketAddress> for Authority
Source§fn from(addr: &SocketAddress) -> Self
fn from(addr: &SocketAddress) -> Self
Source§impl From<&SocketAddress> for SockAddr
Available on crate feature std only.
impl From<&SocketAddress> for SockAddr
std only.Source§fn from(addr: &SocketAddress) -> Self
fn from(addr: &SocketAddress) -> Self
Source§impl From<&SocketAddress> for NodeId
impl From<&SocketAddress> for NodeId
Source§fn from(addr: &SocketAddress) -> Self
fn from(addr: &SocketAddress) -> Self
Source§impl From<SocketAddr> for SocketAddress
impl From<SocketAddr> for SocketAddress
Source§fn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Source§impl From<SocketAddrV4> for SocketAddress
impl From<SocketAddrV4> for SocketAddress
Source§fn from(value: SocketAddrV4) -> Self
fn from(value: SocketAddrV4) -> Self
Source§impl From<SocketAddrV6> for SocketAddress
impl From<SocketAddrV6> for SocketAddress
Source§fn from(value: SocketAddrV6) -> Self
fn from(value: SocketAddrV6) -> Self
Source§impl From<SocketAddress> for HostWithPort
impl From<SocketAddress> for HostWithPort
Source§fn from(addr: SocketAddress) -> Self
fn from(addr: SocketAddress) -> Self
Source§impl From<SocketAddress> for HostWithOptPort
impl From<SocketAddress> for HostWithOptPort
Source§fn from(addr: SocketAddress) -> Self
fn from(addr: SocketAddress) -> Self
Source§impl From<SocketAddress> for Authority
impl From<SocketAddress> for Authority
Source§fn from(addr: SocketAddress) -> Self
fn from(addr: SocketAddress) -> Self
Source§impl From<SocketAddress> for SockAddr
Available on crate feature std only.
impl From<SocketAddress> for SockAddr
std only.Source§fn from(addr: SocketAddress) -> Self
fn from(addr: SocketAddress) -> Self
Source§impl From<SocketAddress> for SocketAddr
impl From<SocketAddress> for SocketAddr
Source§fn from(addr: SocketAddress) -> Self
fn from(addr: SocketAddress) -> Self
Source§impl From<SocketAddress> for NodeId
impl From<SocketAddress> for NodeId
Source§fn from(addr: SocketAddress) -> Self
fn from(addr: SocketAddress) -> Self
Source§impl From<SocketAddress> for ForwardedAuthority
impl From<SocketAddress> for ForwardedAuthority
Source§fn from(value: SocketAddress) -> Self
fn from(value: SocketAddress) -> Self
Source§impl From<SocketAddress> for Domain
Available on crate feature std only.
impl From<SocketAddress> for Domain
std only.Source§fn from(value: SocketAddress) -> Self
fn from(value: SocketAddress) -> Self
Source§impl FromStr for SocketAddress
impl FromStr for SocketAddress
Source§impl Hash for SocketAddress
impl Hash for SocketAddress
Source§impl IntoCanonicalIpAddr for SocketAddress
impl IntoCanonicalIpAddr for SocketAddress
fn into_canonical_ip_addr(self) -> Self
Source§impl PartialEq for SocketAddress
impl PartialEq for SocketAddress
Source§impl PartialEq<SocketAddr> for SocketAddress
impl PartialEq<SocketAddr> for SocketAddress
Source§impl PartialEq<SocketAddress> for SocketAddr
impl PartialEq<SocketAddress> for SocketAddr
Source§impl Serialize for SocketAddress
impl Serialize for SocketAddress
impl StructuralPartialEq for SocketAddress
Source§impl TryFrom<&String> for SocketAddress
impl TryFrom<&String> for SocketAddress
Source§impl TryFrom<&[u8]> for SocketAddress
impl TryFrom<&[u8]> for SocketAddress
Source§impl TryFrom<&str> for SocketAddress
impl TryFrom<&str> for SocketAddress
Source§impl TryFrom<String> for SocketAddress
impl TryFrom<String> for SocketAddress
Auto Trait Implementations§
impl Freeze for SocketAddress
impl RefUnwindSafe for SocketAddress
impl Send for SocketAddress
impl Sync for SocketAddress
impl Unpin for SocketAddress
impl UnsafeUnpin for SocketAddress
impl UnwindSafe for SocketAddress
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> RamaTryFrom<T> for Uwhere
U: TryFrom<T>,
Source§impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for Twhere
U: RamaTryFrom<T, CrateMarker>,
type Error = <U as RamaTryFrom<T, CrateMarker>>::Error
fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<V, F> ValueFormatter<&V> for F
impl<V, F> ValueFormatter<&V> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &&V)
fn format_value(writer: impl ValueWriter, value: &&V)
value to writerSource§impl<V, F> ValueFormatter<Arc<V>> for F
impl<V, F> ValueFormatter<Arc<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Arc<V>)
fn format_value(writer: impl ValueWriter, value: &Arc<V>)
value to writerSource§impl<V, F> ValueFormatter<Box<V>> for F
impl<V, F> ValueFormatter<Box<V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Box<V>)
fn format_value(writer: impl ValueWriter, value: &Box<V>)
value to writerSource§impl<V, F> ValueFormatter<Cow<'_, V>> for F
impl<V, F> ValueFormatter<Cow<'_, V>> for F
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)
value to writerSource§impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
impl<V, F> ValueFormatter<Option<V>> for Fwhere
F: ValueFormatter<V> + ?Sized,
Source§const SHAPE: FieldShape<'static>
const SHAPE: FieldShape<'static>
metrique_require_explicit_impls only.Source§fn format_value(writer: impl ValueWriter, value: &Option<V>)
fn format_value(writer: impl ValueWriter, value: &Option<V>)
value to writer