minicrossterm/crossterm_winapi/examples/cw_handle.rs

23 lines
800 B
Rust
Raw Normal View History

2019-09-21 07:50:53 +10:00
use std::io::Result;
use crossterm_winapi::{Handle, HandleType};
#[allow(unused_variables)]
2019-09-21 07:50:53 +10:00
fn main() -> Result<()> {
// see the description of the types to see what they do.
2019-09-21 07:50:53 +10:00
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 = Handle::from(handle); /* winapi::um::winnt::HANDLE */
2019-09-21 07:50:53 +10:00
Ok(())
}