1#[cfg(feature = "blanket-impl")]
2use crate::ForwardTryCloneToClone;
3#[cfg(not(any(
4 target_arch = "wasm32",
5 target_os = "hermit",
6 target_os = "trusty",
7 target_os = "motor"
8)))]
9use std::{
10 io,
11 os::{
12 fd::{BorrowedFd, OwnedFd},
13 unix::net::{UnixDatagram, UnixListener, UnixStream},
14 },
15};
16
17use crate::{TryClone, TryCloneToOwned};
18
19#[cfg(all(
20 feature = "blanket-impl",
21 not(any(
22 target_arch = "wasm32",
23 target_os = "hermit",
24 target_os = "trusty",
25 target_os = "motor"
26 ))
27))]
28impl !ForwardTryCloneToClone for OwnedFd {}
29#[cfg(not(any(
30 target_arch = "wasm32",
31 target_os = "hermit",
32 target_os = "trusty",
33 target_os = "motor"
34)))]
35impl TryClone for OwnedFd {
36 type Error = io::Error;
37
38 fn try_clone(&self) -> Result<Self, Self::Error> {
39 OwnedFd::try_clone(self)
40 }
41}
42
43#[cfg(all(
44 feature = "blanket-impl",
45 not(any(
46 target_arch = "wasm32",
47 target_os = "hermit",
48 target_os = "trusty",
49 target_os = "motor"
50 ))
51))]
52impl !ForwardTryCloneToClone for BorrowedFd<'_> {}
53#[cfg(not(any(
54 target_arch = "wasm32",
55 target_os = "hermit",
56 target_os = "trusty",
57 target_os = "motor"
58)))]
59impl TryCloneToOwned for BorrowedFd<'_> {
60 type Owned = OwnedFd;
61 type Error = io::Error;
62
63 fn try_clone_to_owned(&self) -> Result<Self::Owned, Self::Error> {
64 BorrowedFd::try_clone_to_owned(self)
65 }
66}
67
68#[cfg(feature = "blanket-impl")]
69impl !ForwardTryCloneToClone for UnixDatagram {}
70impl TryClone for UnixDatagram {
71 type Error = io::Error;
72
73 fn try_clone(&self) -> Result<Self, Self::Error> {
74 UnixDatagram::try_clone(self)
75 }
76}
77
78#[cfg(feature = "blanket-impl")]
79impl !ForwardTryCloneToClone for UnixListener {}
80impl TryClone for UnixListener {
81 type Error = io::Error;
82
83 fn try_clone(&self) -> Result<Self, Self::Error> {
84 UnixListener::try_clone(self)
85 }
86}
87
88#[cfg(feature = "blanket-impl")]
89impl !ForwardTryCloneToClone for UnixStream {}
90impl TryClone for UnixStream {
91 type Error = io::Error;
92
93 fn try_clone(&self) -> Result<Self, Self::Error> {
94 UnixStream::try_clone(self)
95 }
96}