| 1 | //! Unix-specific extensions to the `std::net` types. |
| 2 | |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/; |
| 4 | use sys::c::{self, c_int}; |
| 5 | |
| 6 | use {TcpBuilderrust-analyzer cargo net2 0.2.39 tcp/TcpBuilder#, UdpBuilderrust-analyzer cargo net2 0.2.39 udp/UdpBuilder#}; |
| 7 | use extrust-analyzer cargo net2 0.2.39 ext/::{selfrust-analyzer cargo net2 0.2.39 ext/, AsSockrust-analyzer cargo net2 0.2.39 ext/AsSock#}; |
| 8 | |
| 9 | /// Unix-specific extensions for the `TcpBuilder` type in this library. |
| 10 | pub trait UnixTcpBuilderExtrust-analyzer cargo net2 0.2.39 unix/UnixTcpBuilderExt# { |
| 11 | /// Set value for the `SO_REUSEPORT` option on this socket. |
| 12 | /// |
| 13 | /// This indicates that further calls to `bind` may allow reuse of local |
| 14 | /// addresses. For IPv4 sockets this means that a socket may bind even when |
| 15 | /// there's a socket already listening on this port. |
| 16 | fn reuse_portrust-analyzer cargo net2 0.2.39 unix/UnixTcpBuilderExt#reuse_port().(&self, reuse: bool) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<&Self>; |
| 17 | |
| 18 | /// Check the value of the `SO_REUSEPORT` option on this socket. |
| 19 | fn get_reuse_portrust-analyzer cargo net2 0.2.39 unix/UnixTcpBuilderExt#get_reuse_port().(&self) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<bool>; |
| 20 | } |
| 21 | |
| 22 | impl UnixTcpBuilderExtrust-analyzer cargo net2 0.2.39 unix/UnixTcpBuilderExt# for TcpBuilderrust-analyzer cargo net2 0.2.39 tcp/TcpBuilder# { |
| 23 | fn reuse_portrust-analyzer cargo net2 0.2.39 unix/impl#[TcpBuilder][UnixTcpBuilderExt]reuse_port().(&self, reuse: bool) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<&Selfrust-analyzer cargo net2 0.2.39 unix/impl#[TcpBuilder][UnixTcpBuilderExt]> { |
| 24 | extrust-analyzer cargo net2 0.2.39 ext/::set_optrust-analyzer cargo net2 0.2.39 ext/set_opt().(self.as_sockrust-analyzer cargo net2 0.2.39 ext/impl#[T][AsSock]as_sock().(), crust-analyzer cargo net2 0.2.39 sys/c/::SOL_SOCKETrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/arch/generic/SOL_SOCKET., crust-analyzer cargo net2 0.2.39 sys/c/::SO_REUSEPORTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/arch/generic/SO_REUSEPORT., |
| 25 | reuse as c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int#).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|()| self) |
| 26 | } |
| 27 | |
| 28 | fn get_reuse_portrust-analyzer cargo net2 0.2.39 unix/impl#[TcpBuilder][UnixTcpBuilderExt]get_reuse_port().(&self) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<bool> { |
| 29 | extrust-analyzer cargo net2 0.2.39 ext/::get_optrust-analyzer cargo net2 0.2.39 ext/get_opt().(self.as_sockrust-analyzer cargo net2 0.2.39 ext/impl#[T][AsSock]as_sock().(), crust-analyzer cargo net2 0.2.39 sys/c/::SOL_SOCKETrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/arch/generic/SOL_SOCKET., crust-analyzer cargo net2 0.2.39 sys/c/::SO_REUSEPORTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/arch/generic/SO_REUSEPORT.) |
| 30 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(extrust-analyzer cargo net2 0.2.39 ext/::int2boolrust-analyzer cargo net2 0.2.39 ext/int2bool().) |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | /// Unix-specific extensions for the `UdpBuilder` type in this library. |
| 35 | pub trait UnixUdpBuilderExtrust-analyzer cargo net2 0.2.39 unix/UnixUdpBuilderExt# { |
| 36 | /// Set value for the `SO_REUSEPORT` option on this socket. |
| 37 | /// |
| 38 | /// This indicates that further calls to `bind` may allow reuse of local |
| 39 | /// addresses. For IPv4 sockets this means that a socket may bind even when |
| 40 | /// there's a socket already listening on this port. |
| 41 | fn reuse_portrust-analyzer cargo net2 0.2.39 unix/UnixUdpBuilderExt#reuse_port().(&self, reuse: bool) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<&Self>; |
| 42 | |
| 43 | /// Check the value of the `SO_REUSEPORT` option on this socket. |
| 44 | fn get_reuse_portrust-analyzer cargo net2 0.2.39 unix/UnixUdpBuilderExt#get_reuse_port().(&self) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<bool>; |
| 45 | } |
| 46 | |
| 47 | impl UnixUdpBuilderExtrust-analyzer cargo net2 0.2.39 unix/UnixUdpBuilderExt# for UdpBuilderrust-analyzer cargo net2 0.2.39 udp/UdpBuilder# { |
| 48 | fn reuse_portrust-analyzer cargo net2 0.2.39 unix/impl#[UdpBuilder][UnixUdpBuilderExt]reuse_port().(&self, reuse: bool) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<&Selfrust-analyzer cargo net2 0.2.39 unix/impl#[UdpBuilder][UnixUdpBuilderExt]> { |
| 49 | extrust-analyzer cargo net2 0.2.39 ext/::set_optrust-analyzer cargo net2 0.2.39 ext/set_opt().(self.as_sockrust-analyzer cargo net2 0.2.39 ext/impl#[T][AsSock]as_sock().(), crust-analyzer cargo net2 0.2.39 sys/c/::SOL_SOCKETrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/arch/generic/SOL_SOCKET., crust-analyzer cargo net2 0.2.39 sys/c/::SO_REUSEPORTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/arch/generic/SO_REUSEPORT., |
| 50 | reuse as c_intrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/primitives/c_int#).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(|()| self) |
| 51 | } |
| 52 | |
| 53 | fn get_reuse_portrust-analyzer cargo net2 0.2.39 unix/impl#[UdpBuilder][UnixUdpBuilderExt]get_reuse_port().(&self) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<bool> { |
| 54 | extrust-analyzer cargo net2 0.2.39 ext/::get_optrust-analyzer cargo net2 0.2.39 ext/get_opt().(self.as_sockrust-analyzer cargo net2 0.2.39 ext/impl#[T][AsSock]as_sock().(), crust-analyzer cargo net2 0.2.39 sys/c/::SOL_SOCKETrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/arch/generic/SOL_SOCKET., crust-analyzer cargo net2 0.2.39 sys/c/::SO_REUSEPORTrust-analyzer cargo libc 0.2.189 unix/linux_like/linux/arch/generic/SO_REUSEPORT.) |
| 55 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map().(extrust-analyzer cargo net2 0.2.39 ext/::int2boolrust-analyzer cargo net2 0.2.39 ext/int2bool().) |
| 56 | } |
| 57 | } |