Skip to main content

SocketAddress

Struct SocketAddress 

Source
pub struct SocketAddress {
    pub ip_addr: IpAddr,
    pub port: u16,
}
Expand description

An IpAddr with an associated port (u16)

Fields§

§ip_addr: IpAddr§port: u16

Implementations§

Source§

impl SocketAddress

Source

pub const fn new(ip_addr: IpAddr, port: u16) -> Self

creates a new SocketAddress

Source

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());
Source

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());
Source

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());
Source

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());
Source

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.

Source

pub fn from_std(addr: SocketAddr) -> Self

Create a SocketAddress from the std SocketAddr version.

Source

pub fn into_std(self) -> SocketAddr

Turn the SocketAddress into the std SocketAddr version.

Source

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());
Source

pub fn with_ip(self, ip_addr: IpAddr) -> Self

Set IpAddr as the ip of SocketAddress

Source

pub fn set_ip(&mut self, ip_addr: IpAddr) -> &mut Self

Set IpAddr as the ip of SocketAddress

Source

pub fn with_ipv4(self, ip_addr: Ipv4Addr) -> Self

Set Ipv4Addr as the ip of SocketAddress

Source

pub fn set_ipv4(&mut self, ip_addr: Ipv4Addr) -> &mut Self

Set Ipv4Addr as the ip of SocketAddress

Source

pub fn with_ipv6(self, ip_addr: Ipv6Addr) -> Self

Set Ipv6Addr as the ip of SocketAddress

Source

pub fn set_ipv6(&mut self, ip_addr: Ipv6Addr) -> &mut Self

Set Ipv6Addr as the ip of SocketAddress

Source

pub fn with_port(self, port: u16) -> Self

Set port (u16) of SocketAddress

Source

pub fn set_port(&mut self, port: u16) -> &mut Self

Set port (u16) of SocketAddress

Trait Implementations§

Source§

impl Clone for SocketAddress

Source§

fn clone(&self) -> SocketAddress

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SocketAddress

Source§

impl Debug for SocketAddress

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SocketAddress

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for SocketAddress

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SocketAddress

Source§

impl From<&SocketAddr> for SocketAddress

Source§

fn from(addr: &SocketAddr) -> Self

Converts to this type from the input type.
Source§

impl From<&SocketAddress> for HostWithPort

Source§

fn from(addr: &SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<&SocketAddress> for HostWithOptPort

Source§

fn from(addr: &SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<&SocketAddress> for Authority

Source§

fn from(addr: &SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<&SocketAddress> for SockAddr

Available on crate feature std only.
Source§

fn from(addr: &SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<&SocketAddress> for NodeId

Source§

fn from(addr: &SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<(IpAddr, u16)> for SocketAddress

Source§

fn from((ip_addr, port): (IpAddr, u16)) -> Self

Converts to this type from the input type.
Source§

impl From<(Ipv4Addr, u16)> for SocketAddress

Source§

fn from((ip, port): (Ipv4Addr, u16)) -> Self

Converts to this type from the input type.
Source§

impl From<(Ipv6Addr, u16)> for SocketAddress

Source§

fn from((ip, port): (Ipv6Addr, u16)) -> Self

Converts to this type from the input type.
Source§

impl From<([u8; 4], u16)> for SocketAddress

Source§

fn from((ip, port): ([u8; 4], u16)) -> Self

Converts to this type from the input type.
Source§

impl From<([u8; 16], u16)> for SocketAddress

Source§

fn from((ip, port): ([u8; 16], u16)) -> Self

Converts to this type from the input type.
Source§

impl From<([u16; 8], u16)> for SocketAddress

Source§

fn from((ip, port): ([u16; 8], u16)) -> Self

Converts to this type from the input type.
Source§

impl From<SocketAddr> for SocketAddress

Source§

fn from(addr: SocketAddr) -> Self

Converts to this type from the input type.
Source§

impl From<SocketAddrV4> for SocketAddress

Source§

fn from(value: SocketAddrV4) -> Self

Converts to this type from the input type.
Source§

impl From<SocketAddrV6> for SocketAddress

Source§

fn from(value: SocketAddrV6) -> Self

Converts to this type from the input type.
Source§

impl From<SocketAddress> for HostWithPort

Source§

fn from(addr: SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<SocketAddress> for HostWithOptPort

Source§

fn from(addr: SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<SocketAddress> for Authority

Source§

fn from(addr: SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<SocketAddress> for SockAddr

Available on crate feature std only.
Source§

fn from(addr: SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<SocketAddress> for SocketAddr

Source§

fn from(addr: SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<SocketAddress> for NodeId

Source§

fn from(addr: SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<SocketAddress> for ForwardedAuthority

Source§

fn from(value: SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl From<SocketAddress> for Domain

Available on crate feature std only.
Source§

fn from(value: SocketAddress) -> Self

Converts to this type from the input type.
Source§

impl FromStr for SocketAddress

Source§

type Err = Box<dyn Error + Sync + Send>

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for SocketAddress

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoCanonicalIpAddr for SocketAddress

Source§

impl PartialEq for SocketAddress

Source§

fn eq(&self, other: &SocketAddress) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<SocketAddr> for SocketAddress

Source§

fn eq(&self, other: &SocketAddr) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<SocketAddress> for SocketAddr

Source§

fn eq(&self, other: &SocketAddress) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for SocketAddress

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SocketAddress

Source§

impl TryFrom<&String> for SocketAddress

Source§

type Error = Box<dyn Error + Sync + Send>

The type returned in the event of a conversion error.
Source§

fn try_from(value: &String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&[u8]> for SocketAddress

Source§

type Error = Box<dyn Error + Sync + Send>

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&str> for SocketAddress

Source§

type Error = Box<dyn Error + Sync + Send>

The type returned in the event of a conversion error.
Source§

fn try_from(s: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<String> for SocketAddress

Source§

type Error = Box<dyn Error + Sync + Send>

The type returned in the event of a conversion error.
Source§

fn try_from(s: String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Vec<u8>> for SocketAddress

Source§

type Error = Box<dyn Error + Sync + Send>

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> RamaFrom<T> for U
where U: From<T>,

Source§

fn rama_from(value: T) -> U

Source§

impl<T, U, CrateMarker> RamaInto<U, CrateMarker> for T
where U: RamaFrom<T, CrateMarker>,

Source§

fn rama_into(self) -> U

Source§

impl<T, U> RamaTryFrom<T> for U
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

Source§

fn rama_try_from(value: T) -> Result<U, <U as RamaTryFrom<T>>::Error>

Source§

impl<T, U, CrateMarker> RamaTryInto<U, CrateMarker> for T
where U: RamaTryFrom<T, CrateMarker>,

Source§

type Error = <U as RamaTryFrom<T, CrateMarker>>::Error

Source§

fn rama_try_into(self) -> Result<U, <U as RamaTryFrom<T, CrateMarker>>::Error>

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<V, F> ValueFormatter<&V> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

Source§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
Source§

fn format_value(writer: impl ValueWriter, value: &&V)

Write value to writer
Source§

impl<V, F> ValueFormatter<Arc<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

Source§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
Source§

fn format_value(writer: impl ValueWriter, value: &Arc<V>)

Write value to writer
Source§

impl<V, F> ValueFormatter<Box<V>> for F
where F: ValueFormatter<V> + ?Sized, V: ?Sized,

Source§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
Source§

fn format_value(writer: impl ValueWriter, value: &Box<V>)

Write value to writer
Source§

impl<V, F> ValueFormatter<Cow<'_, V>> for F
where V: ToOwned + ?Sized, F: ValueFormatter<V> + ?Sized,

Source§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
Source§

fn format_value(writer: impl ValueWriter, value: &Cow<'_, V>)

Write value to writer
Source§

impl<V, F> ValueFormatter<Option<V>> for F
where F: ValueFormatter<V> + ?Sized,

Source§

const SHAPE: FieldShape<'static>

Available on non-metrique_require_explicit_impls only.
The shape of values produced by this formatter. Read more
Source§

fn format_value(writer: impl ValueWriter, value: &Option<V>)

Write value to writer
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more