]>
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 | ||
c1a9b12d SL |
35 | impl IntoRawHandle for process::Child { |
36 | fn into_raw_handle(self) -> RawHandle { | |
37 | self.into_inner().into_handle().into_raw() as *mut _ | |
38 | } | |
39 | } | |
40 | ||
62682a34 SL |
41 | #[stable(feature = "process_extensions", since = "1.2.0")] |
42 | impl AsRawHandle for process::ChildStdin { | |
43 | fn as_raw_handle(&self) -> RawHandle { | |
44 | self.as_inner().handle().raw() as *mut _ | |
45 | } | |
46 | } | |
47 | ||
48 | #[stable(feature = "process_extensions", since = "1.2.0")] | |
49 | impl AsRawHandle for process::ChildStdout { | |
50 | fn as_raw_handle(&self) -> RawHandle { | |
51 | self.as_inner().handle().raw() as *mut _ | |
52 | } | |
53 | } | |
54 | ||
55 | #[stable(feature = "process_extensions", since = "1.2.0")] | |
56 | impl AsRawHandle for process::ChildStderr { | |
57 | fn as_raw_handle(&self) -> RawHandle { | |
58 | self.as_inner().handle().raw() as *mut _ | |
59 | } | |
60 | } | |
c1a9b12d SL |
61 | |
62 | impl IntoRawHandle for process::ChildStdin { | |
63 | fn into_raw_handle(self) -> RawHandle { | |
64 | self.into_inner().into_handle().into_raw() as *mut _ | |
65 | } | |
66 | } | |
67 | ||
68 | impl IntoRawHandle for process::ChildStdout { | |
69 | fn into_raw_handle(self) -> RawHandle { | |
70 | self.into_inner().into_handle().into_raw() as *mut _ | |
71 | } | |
72 | } | |
73 | ||
74 | impl IntoRawHandle for process::ChildStderr { | |
75 | fn into_raw_handle(self) -> RawHandle { | |
76 | self.into_inner().into_handle().into_raw() as *mut _ | |
77 | } | |
78 | } |