Skip to content

Commit

Permalink
Add SockAddr::as_storage
Browse files Browse the repository at this point in the history
Returns the underlying storage.
  • Loading branch information
Thomasdezeeuw committed Mar 21, 2023
1 parent 26ad768 commit 4c55898
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/sockaddr.rs
Expand Up @@ -173,6 +173,11 @@ impl SockAddr {
ptr::addr_of!(self.storage).cast()
}

/// Retuns the address as the storage.
pub const fn as_storage(self) -> sockaddr_storage {
self.storage
}

/// Returns true if this address is in the `AF_INET` (IPv4) family, false otherwise.
pub const fn is_ipv4(&self) -> bool {
self.storage.ss_family == AF_INET as sa_family_t
Expand Down

0 comments on commit 4c55898

Please sign in to comment.