Helper for implementing `SocketAddrArg::with_sockaddr`. # Safety This calls `f` with a pointer to an object it has a reference to, with the and the length of that object, so they'll be valid for the duration of the call.
(
addr: &A,
f: impl FnOnce(*const SocketAddrOpaque, SocketAddrLen) -> R,
)
| 107 | /// and the length of that object, so they'll be valid for the duration of the |
| 108 | /// call. |
| 109 | pub(crate) unsafe fn call_with_sockaddr<A, R>( |
| 110 | addr: &A, |
| 111 | f: impl FnOnce(*const SocketAddrOpaque, SocketAddrLen) -> R, |
| 112 | ) -> R { |
| 113 | let ptr = as_ptr(addr).cast(); |
| 114 | let len = size_of::<A>() as SocketAddrLen; |
| 115 | f(ptr, len) |
| 116 | } |
| 117 | |
| 118 | // SAFETY: This just forwards to the inner `SocketAddrArg` implementations. |
| 119 | unsafe impl SocketAddrArg for SocketAddr { |
no test coverage detected