Skip to main content

gio_win32/auto/
output_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::{SignalHandlerId, connect_raw},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// ` belongs to the Windows-specific GIO
15    /// interfaces, thus you have to use the `gio-windows-2.0.pc` pkg-config file
16    /// when using it.
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `close-handle`
22    ///  Whether to close the file handle when the stream is closed.
23    ///
24    /// Readable | Writable
25    ///
26    ///
27    /// #### `handle`
28    ///  The file handle that the stream writes to.
29    ///
30    /// Readable | Writable | Construct Only
31    ///
32    /// # Implements
33    ///
34    /// [`Win32OutputStreamExt`][trait@crate::prelude::Win32OutputStreamExt], [`trait@gio::prelude::OutputStreamExt`], [`Win32OutputStreamExtManual`][trait@crate::prelude::Win32OutputStreamExtManual]
35    #[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
47/// Trait containing all [`struct@OutputStream`] methods.
48///
49/// # Implementors
50///
51/// [`OutputStream`][struct@crate::OutputStream]
52pub trait Win32OutputStreamExt: IsA<OutputStream> + 'static {
53    /// Returns whether the handle of @self will be closed when the
54    /// stream is closed.
55    ///
56    /// # Returns
57    ///
58    /// [`true`] if the handle is closed when done
59    #[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    /// Sets whether the handle of @self shall be closed when the stream
71    /// is closed.
72    /// ## `close_handle`
73    /// [`true`] to close the handle when done
74    #[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 {}