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::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// `GWin32OutputStream` implements [`gio::OutputStream`][crate::gio::OutputStream] for writing to a
15    /// Windows file handle.
16    ///
17    /// Note that `<gio/gwin32outputstream.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 file handle that the stream writes to.
32    ///
33    /// Readable | Writeable | Construct Only
34    ///
35    /// # Implements
36    ///
37    /// [`Win32OutputStreamExt`][trait@crate::prelude::Win32OutputStreamExt], [`trait@gio::prelude::OutputStreamExt`], [`Win32OutputStreamExtManual`][trait@crate::prelude::Win32OutputStreamExtManual]
38    #[doc(alias = "GWin32OutputStream")]
39    pub struct OutputStream(Object<ffi::GWin32OutputStream, ffi::GWin32OutputStreamClass>) @extends gio::OutputStream;
40
41    match fn {
42        type_ => || ffi::g_win32_output_stream_get_type(),
43    }
44}
45
46impl OutputStream {
47    pub const NONE: Option<&'static OutputStream> = None;
48}
49
50/// Trait containing all [`struct@OutputStream`] methods.
51///
52/// # Implementors
53///
54/// [`OutputStream`][struct@crate::OutputStream]
55pub trait Win32OutputStreamExt: IsA<OutputStream> + 'static {
56    /// Returns whether the handle of @self will be closed when the
57    /// stream is closed.
58    ///
59    /// # Returns
60    ///
61    /// [`true`] if the handle is closed when done
62    #[doc(alias = "g_win32_output_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_output_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 when the stream
74    /// is closed.
75    /// ## `close_handle`
76    /// [`true`] to close the handle when done
77    #[doc(alias = "g_win32_output_stream_set_close_handle")]
78    #[doc(alias = "close-handle")]
79    unsafe fn set_close_handle(&self, close_handle: bool) {
80        ffi::g_win32_output_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<OutputStream>,
90            F: Fn(&P) + 'static,
91        >(
92            this: *mut ffi::GWin32OutputStream,
93            _param_spec: glib::ffi::gpointer,
94            f: glib::ffi::gpointer,
95        ) {
96            let f: &F = &*(f as *const F);
97            f(OutputStream::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<OutputStream>> Win32OutputStreamExt for O {}