use SockaddrLike or SockaddrStorage instead
socket
only.Expand description
Represents a socket address
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Inet(InetAddr)
use SockaddrLike or SockaddrStorage instead
net
only.Unix(UnixAddr)
use SockaddrLike or SockaddrStorage instead
Link(LinkAddr)
use SockaddrLike or SockaddrStorage instead
net
only.Datalink address (MAC)
Implementations
sourceimpl SockAddr
impl SockAddr
pub fn new_inet(addr: InetAddr) -> SockAddr
net
only.pub fn new_unix<P: ?Sized + NixPath>(path: &P) -> Result<SockAddr>
pub fn family(&self) -> AddressFamily
pub fn to_str(&self) -> String
use .to_string() instead
sourcepub fn as_ffi_pair(&self) -> (&sockaddr, socklen_t)
pub fn as_ffi_pair(&self) -> (&sockaddr, socklen_t)
Conversion from nix’s SockAddr type to the underlying libc sockaddr type.
This is useful for interfacing with other libc functions that don’t yet have nix wrappers. Returns a reference to the underlying data type (as a sockaddr reference) along with the size of the actual data type. sockaddr is commonly used as a proxy for a superclass as C doesn’t support inheritance, so many functions that take a sockaddr * need to take the size of the underlying type as well and then internally cast it back.
Trait Implementations
sourceimpl SockaddrLike for SockAddr
impl SockaddrLike for SockAddr
sourceunsafe fn from_raw(
addr: *const sockaddr,
_len: Option<socklen_t>
) -> Option<Self>
unsafe fn from_raw(
addr: *const sockaddr,
_len: Option<socklen_t>
) -> Option<Self>
Unsafe constructor from a variable length source Read more
sourcefn as_ptr(&self) -> *const sockaddr
fn as_ptr(&self) -> *const sockaddr
Returns a raw pointer to the inner structure. Useful for FFI.
sourcefn family(&self) -> Option<AddressFamily>
fn family(&self) -> Option<AddressFamily>
Return the address family of this socket Read more
impl Copy for SockAddr
impl Eq for SockAddr
impl StructuralEq for SockAddr
impl StructuralPartialEq for SockAddr
Auto Trait Implementations
impl RefUnwindSafe for SockAddr
impl Send for SockAddr
impl Sync for SockAddr
impl Unpin for SockAddr
impl UnwindSafe for SockAddr
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more