Lines 28-49
Link Here
|
28 |
//! [from+into conversions]: FromFilelike::from_into_filelike |
28 |
//! [from+into conversions]: FromFilelike::from_into_filelike |
29 |
|
29 |
|
30 |
#![deny(missing_docs)] |
30 |
#![deny(missing_docs)] |
31 |
#![cfg_attr(rustc_attrs, feature(rustc_attrs))] |
|
|
32 |
// Work around https://github.com/rust-lang/rust/issues/103306. |
31 |
// Work around https://github.com/rust-lang/rust/issues/103306. |
33 |
#![cfg_attr(all(wasi_ext, target_os = "wasi"), feature(wasi_ext))] |
32 |
#![cfg_attr(all(wasi_ext, target_os = "wasi"), feature(wasi_ext))] |
|
|
33 |
// Currently supported platforms. |
34 |
#![cfg(any(unix, windows, target_os = "wasi"))] |
34 |
|
35 |
|
35 |
mod portability; |
36 |
mod portability; |
36 |
mod traits; |
37 |
mod traits; |
37 |
#[cfg(not(io_lifetimes_use_std))] |
38 |
#[cfg(not(io_safety_is_in_std))] |
38 |
mod types; |
39 |
mod types; |
39 |
|
40 |
|
40 |
#[cfg(not(io_lifetimes_use_std))] |
41 |
#[cfg(not(io_safety_is_in_std))] |
41 |
mod impls_std; |
42 |
mod impls_std; |
42 |
|
43 |
|
43 |
#[cfg(not(io_lifetimes_use_std))] |
44 |
#[cfg(not(io_safety_is_in_std))] |
44 |
#[cfg(any(unix, target_os = "wasi"))] |
45 |
#[cfg(any(unix, target_os = "wasi"))] |
45 |
pub use traits::AsFd; |
46 |
pub use traits::AsFd; |
46 |
#[cfg(not(io_lifetimes_use_std))] |
47 |
#[cfg(not(io_safety_is_in_std))] |
47 |
#[cfg(windows)] |
48 |
#[cfg(windows)] |
48 |
pub use traits::{AsHandle, AsSocket}; |
49 |
pub use traits::{AsHandle, AsSocket}; |
49 |
#[cfg(any(unix, target_os = "wasi"))] |
50 |
#[cfg(any(unix, target_os = "wasi"))] |
Lines 53-75
pub use traits::{FromFd, IntoFd};
Link Here
|
53 |
#[allow(deprecated)] |
54 |
#[allow(deprecated)] |
54 |
pub use traits::{FromHandle, FromSocket, IntoHandle, IntoSocket}; |
55 |
pub use traits::{FromHandle, FromSocket, IntoHandle, IntoSocket}; |
55 |
|
56 |
|
56 |
#[cfg(not(io_lifetimes_use_std))] |
57 |
#[cfg(not(io_safety_is_in_std))] |
57 |
#[cfg(any(unix, target_os = "wasi"))] |
58 |
#[cfg(any(unix, target_os = "wasi"))] |
58 |
pub use types::{BorrowedFd, OwnedFd}; |
59 |
pub use types::{BorrowedFd, OwnedFd}; |
59 |
#[cfg(not(io_lifetimes_use_std))] |
60 |
#[cfg(not(io_safety_is_in_std))] |
60 |
#[cfg(windows)] |
61 |
#[cfg(windows)] |
61 |
pub use types::{ |
62 |
pub use types::{ |
62 |
BorrowedHandle, BorrowedSocket, HandleOrInvalid, InvalidHandleError, NullHandleError, |
63 |
BorrowedHandle, BorrowedSocket, HandleOrInvalid, InvalidHandleError, NullHandleError, |
63 |
OwnedHandle, OwnedSocket, |
64 |
OwnedHandle, OwnedSocket, |
64 |
}; |
65 |
}; |
65 |
|
66 |
|
66 |
#[cfg(io_lifetimes_use_std)] |
67 |
#[cfg(io_safety_is_in_std)] |
67 |
#[cfg(unix)] |
68 |
#[cfg(unix)] |
68 |
pub use std::os::unix::io::{AsFd, BorrowedFd, OwnedFd}; |
69 |
pub use std::os::unix::io::{AsFd, BorrowedFd, OwnedFd}; |
69 |
#[cfg(io_lifetimes_use_std)] |
70 |
#[cfg(io_safety_is_in_std)] |
70 |
#[cfg(target_os = "wasi")] |
71 |
#[cfg(target_os = "wasi")] |
71 |
pub use std::os::wasi::io::{AsFd, BorrowedFd, OwnedFd}; |
72 |
pub use std::os::wasi::io::{AsFd, BorrowedFd, OwnedFd}; |
72 |
#[cfg(io_lifetimes_use_std)] |
73 |
#[cfg(io_safety_is_in_std)] |
73 |
#[cfg(windows)] |
74 |
#[cfg(windows)] |
74 |
pub use std::os::windows::io::{ |
75 |
pub use std::os::windows::io::{ |
75 |
AsHandle, AsSocket, BorrowedHandle, BorrowedSocket, HandleOrInvalid, InvalidHandleError, |
76 |
AsHandle, AsSocket, BorrowedHandle, BorrowedSocket, HandleOrInvalid, InvalidHandleError, |
Lines 87-93
pub use std::os::windows::io::{
Link Here
|
87 |
// |
88 |
// |
88 |
// So we define `FromFd`/`IntoFd` traits, and implement them in terms of |
89 |
// So we define `FromFd`/`IntoFd` traits, and implement them in terms of |
89 |
// `From`/`Into`, |
90 |
// `From`/`Into`, |
90 |
#[cfg(io_lifetimes_use_std)] |
91 |
#[cfg(io_safety_is_in_std)] |
91 |
#[cfg(any(unix, target_os = "wasi"))] |
92 |
#[cfg(any(unix, target_os = "wasi"))] |
92 |
#[allow(deprecated)] |
93 |
#[allow(deprecated)] |
93 |
impl<T: From<OwnedFd>> FromFd for T { |
94 |
impl<T: From<OwnedFd>> FromFd for T { |
Lines 96-102
impl<T: From<OwnedFd>> FromFd for T {
Link Here
|
96 |
owned_fd.into() |
97 |
owned_fd.into() |
97 |
} |
98 |
} |
98 |
} |
99 |
} |
99 |
#[cfg(io_lifetimes_use_std)] |
100 |
#[cfg(io_safety_is_in_std)] |
100 |
#[cfg(any(unix, target_os = "wasi"))] |
101 |
#[cfg(any(unix, target_os = "wasi"))] |
101 |
#[allow(deprecated)] |
102 |
#[allow(deprecated)] |
102 |
impl<T> IntoFd for T |
103 |
impl<T> IntoFd for T |
Lines 109-115
where
Link Here
|
109 |
} |
110 |
} |
110 |
} |
111 |
} |
111 |
|
112 |
|
112 |
#[cfg(io_lifetimes_use_std)] |
113 |
#[cfg(io_safety_is_in_std)] |
113 |
#[cfg(windows)] |
114 |
#[cfg(windows)] |
114 |
#[allow(deprecated)] |
115 |
#[allow(deprecated)] |
115 |
impl<T: From<OwnedHandle>> FromHandle for T { |
116 |
impl<T: From<OwnedHandle>> FromHandle for T { |
Lines 118-124
impl<T: From<OwnedHandle>> FromHandle for T {
Link Here
|
118 |
owned_handle.into() |
119 |
owned_handle.into() |
119 |
} |
120 |
} |
120 |
} |
121 |
} |
121 |
#[cfg(io_lifetimes_use_std)] |
122 |
#[cfg(io_safety_is_in_std)] |
122 |
#[cfg(windows)] |
123 |
#[cfg(windows)] |
123 |
#[allow(deprecated)] |
124 |
#[allow(deprecated)] |
124 |
impl<T> IntoHandle for T |
125 |
impl<T> IntoHandle for T |
Lines 131-137
where
Link Here
|
131 |
} |
132 |
} |
132 |
} |
133 |
} |
133 |
|
134 |
|
134 |
#[cfg(io_lifetimes_use_std)] |
135 |
#[cfg(io_safety_is_in_std)] |
135 |
#[cfg(windows)] |
136 |
#[cfg(windows)] |
136 |
#[allow(deprecated)] |
137 |
#[allow(deprecated)] |
137 |
impl<T: From<OwnedSocket>> FromSocket for T { |
138 |
impl<T: From<OwnedSocket>> FromSocket for T { |
Lines 140-146
impl<T: From<OwnedSocket>> FromSocket for T {
Link Here
|
140 |
owned_socket.into() |
141 |
owned_socket.into() |
141 |
} |
142 |
} |
142 |
} |
143 |
} |
143 |
#[cfg(io_lifetimes_use_std)] |
144 |
#[cfg(io_safety_is_in_std)] |
144 |
#[cfg(windows)] |
145 |
#[cfg(windows)] |
145 |
#[allow(deprecated)] |
146 |
#[allow(deprecated)] |
146 |
impl<T> IntoSocket for T |
147 |
impl<T> IntoSocket for T |
Lines 165-186
pub mod views;
Link Here
|
165 |
|
166 |
|
166 |
// Ideally, we'd want crates to implement our traits themselves. But for now, |
167 |
// Ideally, we'd want crates to implement our traits themselves. But for now, |
167 |
// while we're prototyping, we provide a few impls on foreign types. |
168 |
// while we're prototyping, we provide a few impls on foreign types. |
168 |
#[cfg(not(io_lifetimes_use_std))] |
169 |
#[cfg(not(io_safety_is_in_std))] |
169 |
#[cfg(feature = "async-std")] |
170 |
#[cfg(feature = "async-std")] |
170 |
mod impls_async_std; |
171 |
mod impls_async_std; |
171 |
#[cfg(not(io_lifetimes_use_std))] |
172 |
#[cfg(not(io_safety_is_in_std))] |
172 |
#[cfg(feature = "fs-err")] |
173 |
#[cfg(feature = "fs-err")] |
173 |
mod impls_fs_err; |
174 |
mod impls_fs_err; |
174 |
#[cfg(not(io_lifetimes_use_std))] |
175 |
#[cfg(not(io_safety_is_in_std))] |
175 |
#[cfg(feature = "mio")] |
176 |
#[cfg(feature = "mio")] |
176 |
mod impls_mio; |
177 |
mod impls_mio; |
177 |
#[cfg(not(target_os = "wasi"))] |
178 |
#[cfg(not(target_os = "wasi"))] |
178 |
#[cfg(not(io_lifetimes_use_std))] |
179 |
#[cfg(not(io_safety_is_in_std))] |
179 |
#[cfg(feature = "os_pipe")] |
180 |
#[cfg(feature = "os_pipe")] |
180 |
mod impls_os_pipe; |
181 |
mod impls_os_pipe; |
181 |
#[cfg(not(io_lifetimes_use_std))] |
182 |
#[cfg(not(io_safety_is_in_std))] |
182 |
#[cfg(feature = "socket2")] |
183 |
#[cfg(feature = "socket2")] |
183 |
mod impls_socket2; |
184 |
mod impls_socket2; |
184 |
#[cfg(not(io_lifetimes_use_std))] |
185 |
#[cfg(not(io_safety_is_in_std))] |
185 |
#[cfg(feature = "tokio")] |
186 |
#[cfg(feature = "tokio")] |
186 |
mod impls_tokio; |
187 |
mod impls_tokio; |