]>
Commit | Line | Data |
---|---|---|
62682a34 SL |
1 | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | //! Extensions to `std::process` for Windows. | |
12 | ||
13 | #![stable(feature = "process_extensions", since = "1.2.0")] | |
14 | ||
c1a9b12d | 15 | use os::windows::io::{FromRawHandle, RawHandle, AsRawHandle, IntoRawHandle}; |
62682a34 SL |
16 | use process; |
17 | use sys; | |
c1a9b12d | 18 | use sys_common::{AsInner, FromInner, IntoInner}; |
62682a34 SL |
19 | |
20 | #[stable(feature = "process_extensions", since = "1.2.0")] | |
21 | impl FromRawHandle for process::Stdio { | |
22 | unsafe fn from_raw_handle(handle: RawHandle) -> process::Stdio { | |
23 | let handle = sys::handle::Handle::new(handle as *mut _); | |
24 | process::Stdio::from_inner(handle) | |
25 | } | |
26 | } | |
27 | ||
28 | #[stable(feature = "process_extensions", since = "1.2.0")] | |
29 | impl AsRawHandle for process::Child { | |
30 | fn as_raw_handle(&self) -> RawHandle { | |
31 | self.as_inner().handle().raw() as *mut _ | |
32 | } | |
33 | } | |
34 | ||
92a42be0 | 35 | #[stable(feature = "process_extensions", since = "1.2.0")] |
c1a9b12d SL |
36 | impl IntoRawHandle for process::Child { |
37 | fn into_raw_handle(self) -> RawHandle { | |
38 | self.into_inner().into_handle().into_raw() as *mut _ | |
39 | } | |
40 | } | |
41 | ||
62682a34 SL |
42 | #[stable(feature = "process_extensions", since = "1.2.0")] |
43 | impl AsRawHandle for process::ChildStdin { | |
44 | fn as_raw_handle(&self) -> RawHandle { | |
45 | self.as_inner().handle().raw() as *mut _ | |
46 | } | |
47 | } | |
48 | ||
49 | #[stable(feature = "process_extensions", since = "1.2.0")] | |
50 | impl AsRawHandle for process::ChildStdout { | |
51 | fn as_raw_handle(&self) -> RawHandle { | |
52 | self.as_inner().handle().raw() as *mut _ | |
53 | } | |
54 | } | |
55 | ||
56 | #[stable(feature = "process_extensions", since = "1.2.0")] | |
57 | impl AsRawHandle for process::ChildStderr { | |
58 | fn as_raw_handle(&self) -> RawHandle { | |
59 | self.as_inner().handle().raw() as *mut _ | |
60 | } | |
61 | } | |
c1a9b12d | 62 | |
92a42be0 | 63 | #[stable(feature = "process_extensions", since = "1.2.0")] |
c1a9b12d SL |
64 | impl IntoRawHandle for process::ChildStdin { |
65 | fn into_raw_handle(self) -> RawHandle { | |
66 | self.into_inner().into_handle().into_raw() as *mut _ | |
67 | } | |
68 | } | |
69 | ||
92a42be0 | 70 | #[stable(feature = "process_extensions", since = "1.2.0")] |
c1a9b12d SL |
71 | impl IntoRawHandle for process::ChildStdout { |
72 | fn into_raw_handle(self) -> RawHandle { | |
73 | self.into_inner().into_handle().into_raw() as *mut _ | |
74 | } | |
75 | } | |
76 | ||
92a42be0 | 77 | #[stable(feature = "process_extensions", since = "1.2.0")] |
c1a9b12d SL |
78 | impl IntoRawHandle for process::ChildStderr { |
79 | fn into_raw_handle(self) -> RawHandle { | |
80 | self.into_inner().into_handle().into_raw() as *mut _ | |
81 | } | |
82 | } |