#[cfg(windows)]
use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle};
use glib::{prelude::*, translate::*};
use crate::{OutputStream, ffi};
impl OutputStream {
#[doc(alias = "g_win32_output_stream_new")]
#[cfg(windows)]
#[cfg_attr(docsrs, doc(cfg(windows)))]
pub unsafe fn take_handle(handle: impl IntoRawHandle) -> OutputStream {
let handle = handle.into_raw_handle();
let close_handle = true.into_glib();
gio::OutputStream::from_glib_full(ffi::g_win32_output_stream_new(handle, close_handle))
.unsafe_cast()
}
#[doc(alias = "g_win32_output_stream_new")]
#[cfg(windows)]
#[cfg_attr(docsrs, doc(cfg(windows)))]
pub unsafe fn with_handle<T: AsRawHandle>(handle: T) -> OutputStream {
let handle = handle.as_raw_handle();
let close_handle = false.into_glib();
gio::OutputStream::from_glib_full(ffi::g_win32_output_stream_new(handle, close_handle))
.unsafe_cast()
}
}
#[cfg(windows)]
#[cfg_attr(docsrs, doc(cfg(windows)))]
impl AsRawHandle for OutputStream {
fn as_raw_handle(&self) -> RawHandle {
unsafe { ffi::g_win32_output_stream_get_handle(self.to_glib_none().0) as _ }
}
}
pub trait Win32OutputStreamExtManual: IsA<OutputStream> + Sized {
#[doc(alias = "g_win32_output_stream_get_handle")]
#[doc(alias = "get_handle")]
#[cfg(windows)]
#[cfg_attr(docsrs, doc(cfg(windows)))]
fn handle<T: FromRawHandle>(&self) -> T {
unsafe {
T::from_raw_handle(ffi::g_win32_output_stream_get_handle(
self.as_ref().to_glib_none().0,
))
}
}
}
impl<O: IsA<OutputStream>> Win32OutputStreamExtManual for O {}