File: handle.rs

package info (click to toggle)
rust-crossterm-winapi 0.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 204 kB
  • sloc: makefile: 4
file content (30 lines) | stat: -rwxr-xr-x 963 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#[cfg(windows)]
use std::io::Result;

#[cfg(windows)]
use crossterm_winapi::{Handle, HandleType};

#[cfg(windows)]
#[allow(unused_variables)]
fn main() -> Result<()> {
    // see the description of the types to see what they do.
    let out_put_handle = Handle::new(HandleType::OutputHandle)?;
    let out_put_handle = Handle::new(HandleType::InputHandle)?;
    let curr_out_put_handle = Handle::new(HandleType::CurrentOutputHandle)?;
    let curr_out_put_handle = Handle::new(HandleType::CurrentInputHandle)?;

    // now you have this handle you might want to get the WinApi `HANDLE` it is wrapping.
    // you can do this by defencing.

    let handle /*:HANDLE*/ = *out_put_handle;

    // you can also pass you own `HANDLE` to create an instance of `Handle`
    let handle = unsafe { Handle::from_raw(handle) }; /* winapi::um::winnt::HANDLE */

    Ok(())
}

#[cfg(not(windows))]
fn main() {
    println!("This example is for the Windows platform only.");
}