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
26mod sealed {
27    pub trait Sealed {}
28    impl<T: super::IsA<super::FilterInputStream>> Sealed for T {}
29}
30
31pub trait FilterInputStreamExt: IsA<FilterInputStream> + sealed::Sealed + 'static {
32    #[doc(alias = "g_filter_input_stream_get_base_stream")]
33    #[doc(alias = "get_base_stream")]
34    #[doc(alias = "base-stream")]
35    fn base_stream(&self) -> InputStream {
36        unsafe {
37            from_glib_none(ffi::g_filter_input_stream_get_base_stream(
38                self.as_ref().to_glib_none().0,
39            ))
40        }
41    }
42
43    #[doc(alias = "g_filter_input_stream_get_close_base_stream")]
44    #[doc(alias = "get_close_base_stream")]
45    #[doc(alias = "close-base-stream")]
46    fn closes_base_stream(&self) -> bool {
47        unsafe {
48            from_glib(ffi::g_filter_input_stream_get_close_base_stream(
49                self.as_ref().to_glib_none().0,
50            ))
51        }
52    }
53
54    #[doc(alias = "g_filter_input_stream_set_close_base_stream")]
55    #[doc(alias = "close-base-stream")]
56    fn set_close_base_stream(&self, close_base: bool) {
57        unsafe {
58            ffi::g_filter_input_stream_set_close_base_stream(
59                self.as_ref().to_glib_none().0,
60                close_base.into_glib(),
61            );
62        }
63    }
64
65    #[doc(alias = "close-base-stream")]
66    fn connect_close_base_stream_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
67        unsafe extern "C" fn notify_close_base_stream_trampoline<
68            P: IsA<FilterInputStream>,
69            F: Fn(&P) + 'static,
70        >(
71            this: *mut ffi::GFilterInputStream,
72            _param_spec: glib::ffi::gpointer,
73            f: glib::ffi::gpointer,
74        ) {
75            let f: &F = &*(f as *const F);
76            f(FilterInputStream::from_glib_borrow(this).unsafe_cast_ref())
77        }
78        unsafe {
79            let f: Box_<F> = Box_::new(f);
80            connect_raw(
81                self.as_ptr() as *mut _,
82                b"notify::close-base-stream\0".as_ptr() as *const _,
83                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
84                    notify_close_base_stream_trampoline::<Self, F> as *const (),
85                )),
86                Box_::into_raw(f),
87            )
88        }
89    }
90}
91
92impl<O: IsA<FilterInputStream>> FilterInputStreamExt for O {}