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")]
15 pub struct OutputStream(Object<ffi::GWin32OutputStream, ffi::GWin32OutputStreamClass>) @extends gio::OutputStream;
16
17 match fn {
18 type_ => || ffi::g_win32_output_stream_get_type(),
19 }
20}
21
22impl OutputStream {
23 pub const NONE: Option<&'static OutputStream> = None;
24}
25
26pub trait Win32OutputStreamExt: IsA<OutputStream> + 'static {
27 #[doc(alias = "g_win32_output_stream_get_close_handle")]
28 #[doc(alias = "get_close_handle")]
29 #[doc(alias = "close-handle")]
30 fn closes_handle(&self) -> bool {
31 unsafe {
32 from_glib(ffi::g_win32_output_stream_get_close_handle(
33 self.as_ref().to_glib_none().0,
34 ))
35 }
36 }
37
38 #[doc(alias = "g_win32_output_stream_set_close_handle")]
39 #[doc(alias = "close-handle")]
40 unsafe fn set_close_handle(&self, close_handle: bool) {
41 unsafe {
42 ffi::g_win32_output_stream_set_close_handle(
43 self.as_ref().to_glib_none().0,
44 close_handle.into_glib(),
45 );
46 }
47 }
48
49 #[doc(alias = "close-handle")]
50 fn connect_close_handle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
51 unsafe extern "C" fn notify_close_handle_trampoline<
52 P: IsA<OutputStream>,
53 F: Fn(&P) + 'static,
54 >(
55 this: *mut ffi::GWin32OutputStream,
56 _param_spec: glib::ffi::gpointer,
57 f: glib::ffi::gpointer,
58 ) {
59 unsafe {
60 let f: &F = &*(f as *const F);
61 f(OutputStream::from_glib_borrow(this).unsafe_cast_ref())
62 }
63 }
64 unsafe {
65 let f: Box_<F> = Box_::new(f);
66 connect_raw(
67 self.as_ptr() as *mut _,
68 c"notify::close-handle".as_ptr(),
69 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
70 notify_close_handle_trampoline::<Self, F> as *const (),
71 )),
72 Box_::into_raw(f),
73 )
74 }
75 }
76}
77
78impl<O: IsA<OutputStream>> Win32OutputStreamExt for O {}