gio_win32/auto/input_stream.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::ffi;
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 /// `GWin32InputStream` implements [`gio::InputStream`][crate::gio::InputStream] for reading from a
15 /// Windows file handle.
16 ///
17 /// Note that `<gio/gwin32inputstream.h>` belongs to the Windows-specific GIO
18 /// interfaces, thus you have to use the `gio-windows-2.0.pc` pkg-config file
19 /// when using it.
20 ///
21 /// ## Properties
22 ///
23 ///
24 /// #### `close-handle`
25 /// Whether to close the file handle when the stream is closed.
26 ///
27 /// Readable | Writeable
28 ///
29 ///
30 /// #### `handle`
31 /// The handle that the stream reads from.
32 ///
33 /// Readable | Writeable | Construct Only
34 ///
35 /// # Implements
36 ///
37 /// [`Win32InputStreamExt`][trait@crate::prelude::Win32InputStreamExt], [`trait@gio::prelude::InputStreamExt`], [`Win32InputStreamExtManual`][trait@crate::prelude::Win32InputStreamExtManual]
38 #[doc(alias = "GWin32InputStream")]
39 pub struct InputStream(Object<ffi::GWin32InputStream, ffi::GWin32InputStreamClass>) @extends gio::InputStream;
40
41 match fn {
42 type_ => || ffi::g_win32_input_stream_get_type(),
43 }
44}
45
46impl InputStream {
47 pub const NONE: Option<&'static InputStream> = None;
48}
49
50/// Trait containing all [`struct@InputStream`] methods.
51///
52/// # Implementors
53///
54/// [`InputStream`][struct@crate::InputStream]
55pub trait Win32InputStreamExt: IsA<InputStream> + 'static {
56 /// Returns whether the handle of @self will be
57 /// closed when the stream is closed.
58 ///
59 /// # Returns
60 ///
61 /// [`true`] if the handle is closed when done
62 #[doc(alias = "g_win32_input_stream_get_close_handle")]
63 #[doc(alias = "get_close_handle")]
64 #[doc(alias = "close-handle")]
65 fn closes_handle(&self) -> bool {
66 unsafe {
67 from_glib(ffi::g_win32_input_stream_get_close_handle(
68 self.as_ref().to_glib_none().0,
69 ))
70 }
71 }
72
73 /// Sets whether the handle of @self shall be closed
74 /// when the stream is closed.
75 /// ## `close_handle`
76 /// [`true`] to close the handle when done
77 #[doc(alias = "g_win32_input_stream_set_close_handle")]
78 #[doc(alias = "close-handle")]
79 unsafe fn set_close_handle(&self, close_handle: bool) {
80 ffi::g_win32_input_stream_set_close_handle(
81 self.as_ref().to_glib_none().0,
82 close_handle.into_glib(),
83 );
84 }
85
86 #[doc(alias = "close-handle")]
87 fn connect_close_handle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
88 unsafe extern "C" fn notify_close_handle_trampoline<
89 P: IsA<InputStream>,
90 F: Fn(&P) + 'static,
91 >(
92 this: *mut ffi::GWin32InputStream,
93 _param_spec: glib::ffi::gpointer,
94 f: glib::ffi::gpointer,
95 ) {
96 let f: &F = &*(f as *const F);
97 f(InputStream::from_glib_borrow(this).unsafe_cast_ref())
98 }
99 unsafe {
100 let f: Box_<F> = Box_::new(f);
101 connect_raw(
102 self.as_ptr() as *mut _,
103 c"notify::close-handle".as_ptr() as *const _,
104 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
105 notify_close_handle_trampoline::<Self, F> as *const (),
106 )),
107 Box_::into_raw(f),
108 )
109 }
110 }
111}
112
113impl<O: IsA<InputStream>> Win32InputStreamExt for O {}