#[repr(C)]
pub union SockaddrStorage {
    /* private fields */
}
Available on crate feature socket only.
Expand description

A container for any sockaddr type

Just like C’s sockaddr_storage, this type is large enough to hold any type of sockaddr. It can be used as an argument with functions like bind and getsockname. Though it is a union, it can be safely accessed through the as_* methods.

Example

let localhost = SockaddrIn::from_str("127.0.0.1:8081").unwrap();
let fd = socket(AddressFamily::Inet, SockType::Stream, SockFlag::empty(),
    None).unwrap();
bind(fd, &localhost).expect("bind");
let ss: SockaddrStorage = getsockname(fd).expect("getsockname");
assert_eq!(&localhost, ss.as_sockaddr_in().unwrap());

Implementations§

Downcast to an immutable [UnixAddr] reference.

Downcast to a mutable [UnixAddr] reference.

Safely and falliably downcast to an immutable reference

Safely and falliably downcast to a mutable reference

Safely and falliably downcast to an immutable reference

Safely and falliably downcast to a mutable reference

Safely and falliably downcast to an immutable reference

Safely and falliably downcast to a mutable reference

Safely and falliably downcast to an immutable reference

Safely and falliably downcast to a mutable reference

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Unsafe constructor from a variable length source Read more
Returns a raw pointer to the inner structure. Useful for FFI.
Return the address family of this socket Read more
Return the length of valid data in the sockaddr structure. Read more
Return the available space in the structure

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.