gio/auto/
filter_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, InputStream};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GFilterInputStream")]
15    pub struct FilterInputStream(Object<ffi::GFilterInputStream, ffi::GFilterInputStreamClass>) @extends InputStream;
16
17    match fn {
18        type_ => || ffi::g_filter_input_stream_get_type(),
19    }
20}
21
22impl FilterInputStream {
23    pub const NONE: Option<&'static FilterInputStream> = None;
24}
25
26pub trait FilterInputStreamExt: IsA<FilterInputStream> + 'static {
27    #[doc(alias = "g_filter_input_stream_get_base_stream")]
28    #[doc(alias = "get_base_stream")]
29    #[doc(alias = "base-stream")]
30    fn base_stream(&self) -> InputStream {
31        unsafe {
32            from_glib_none(ffi::g_filter_input_stream_get_base_stream(
33                self.as_ref().to_glib_none().0,
34            ))
35        }
36    }
37
38    #[doc(alias = "g_filter_input_stream_get_close_base_stream")]
39    #[doc(alias = "get_close_base_stream")]
40    #[doc(alias = "close-base-stream")]
41    fn closes_base_stream(&self) -> bool {
42        unsafe {
43            from_glib(ffi::g_filter_input_stream_get_close_base_stream(
44                self.as_ref().to_glib_none().0,
45            ))
46        }
47    }
48
49    #[doc(alias = "g_filter_input_stream_set_close_base_stream")]
50    #[doc(alias = "close-base-stream")]
51    fn set_close_base_stream(&self, close_base: bool) {
52        unsafe {
53            ffi::g_filter_input_stream_set_close_base_stream(
54                self.as_ref().to_glib_none().0,
55                close_base.into_glib(),
56            );
57        }
58    }
59
60    #[doc(alias = "close-base-stream")]
61    fn connect_close_base_stream_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
62        unsafe extern "C" fn notify_close_base_stream_trampoline<
63            P: IsA<FilterInputStream>,
64            F: Fn(&P) + 'static,
65        >(
66            this: *mut ffi::GFilterInputStream,
67            _param_spec: glib::ffi::gpointer,
68            f: glib::ffi::gpointer,
69        ) {
70            let f: &F = &*(f as *const F);
71            f(FilterInputStream::from_glib_borrow(this).unsafe_cast_ref())
72        }
73        unsafe {
74            let f: Box_<F> = Box_::new(f);
75            connect_raw(
76                self.as_ptr() as *mut _,
77                c"notify::close-base-stream".as_ptr() as *const _,
78                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
79                    notify_close_base_stream_trampoline::<Self, F> as *const (),
80                )),
81                Box_::into_raw(f),
82            )
83        }
84    }
85}
86
87impl<O: IsA<FilterInputStream>> FilterInputStreamExt for O {}