gio-win32 0.22.6

Rust bindings for the GioWin32 library
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ffi;
use glib::{
    prelude::*,
    signal::{SignalHandlerId, connect_raw},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "GWin32InputStream")]
    pub struct InputStream(Object<ffi::GWin32InputStream, ffi::GWin32InputStreamClass>) @extends gio::InputStream;

    match fn {
        type_ => || ffi::g_win32_input_stream_get_type(),
    }
}

impl InputStream {
    pub const NONE: Option<&'static InputStream> = None;
}

pub trait Win32InputStreamExt: IsA<InputStream> + 'static {
    #[doc(alias = "g_win32_input_stream_get_close_handle")]
    #[doc(alias = "get_close_handle")]
    #[doc(alias = "close-handle")]
    fn closes_handle(&self) -> bool {
        unsafe {
            from_glib(ffi::g_win32_input_stream_get_close_handle(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "g_win32_input_stream_set_close_handle")]
    #[doc(alias = "close-handle")]
    unsafe fn set_close_handle(&self, close_handle: bool) {
        unsafe {
            ffi::g_win32_input_stream_set_close_handle(
                self.as_ref().to_glib_none().0,
                close_handle.into_glib(),
            );
        }
    }

    #[doc(alias = "close-handle")]
    fn connect_close_handle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_close_handle_trampoline<
            P: IsA<InputStream>,
            F: Fn(&P) + 'static,
        >(
            this: *mut ffi::GWin32InputStream,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                let f: &F = &*(f as *const F);
                f(InputStream::from_glib_borrow(this).unsafe_cast_ref())
            }
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                c"notify::close-handle".as_ptr(),
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_close_handle_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<InputStream>> Win32InputStreamExt for O {}