gio_win32/auto/
output_stream.rs1use crate::ffi;
6use glib::{
7 prelude::*,
8 signal::{SignalHandlerId, connect_raw},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GWin32OutputStream")]
36 pub struct OutputStream(Object<ffi::GWin32OutputStream, ffi::GWin32OutputStreamClass>) @extends gio::OutputStream;
37
38 match fn {
39 type_ => || ffi::g_win32_output_stream_get_type(),
40 }
41}
42
43impl OutputStream {
44 pub const NONE: Option<&'static OutputStream> = None;
45}
46
47pub trait Win32OutputStreamExt: IsA<OutputStream> + 'static {
53 #[doc(alias = "g_win32_output_stream_get_close_handle")]
60 #[doc(alias = "get_close_handle")]
61 #[doc(alias = "close-handle")]
62 fn closes_handle(&self) -> bool {
63 unsafe {
64 from_glib(ffi::g_win32_output_stream_get_close_handle(
65 self.as_ref().to_glib_none().0,
66 ))
67 }
68 }
69
70 #[doc(alias = "g_win32_output_stream_set_close_handle")]
75 #[doc(alias = "close-handle")]
76 unsafe fn set_close_handle(&self, close_handle: bool) {
77 unsafe {
78 ffi::g_win32_output_stream_set_close_handle(
79 self.as_ref().to_glib_none().0,
80 close_handle.into_glib(),
81 );
82 }
83 }
84
85 #[doc(alias = "close-handle")]
86 fn connect_close_handle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
87 unsafe extern "C" fn notify_close_handle_trampoline<
88 P: IsA<OutputStream>,
89 F: Fn(&P) + 'static,
90 >(
91 this: *mut ffi::GWin32OutputStream,
92 _param_spec: glib::ffi::gpointer,
93 f: glib::ffi::gpointer,
94 ) {
95 unsafe {
96 let f: &F = &*(f as *const F);
97 f(OutputStream::from_glib_borrow(this).unsafe_cast_ref())
98 }
99 }
100 unsafe {
101 let f: Box_<F> = Box_::new(f);
102 connect_raw(
103 self.as_ptr() as *mut _,
104 c"notify::close-handle".as_ptr(),
105 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
106 notify_close_handle_trampoline::<Self, F> as *const (),
107 )),
108 Box_::into_raw(f),
109 )
110 }
111 }
112}
113
114impl<O: IsA<OutputStream>> Win32OutputStreamExt for O {}