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    /// Base class for input stream implementations that perform some
15    /// kind of filtering operation on a base stream. Typical examples
16    /// of filtering operations are character set conversion, compression
17    /// and byte order flipping.
18    ///
19    /// This is an Abstract Base Class, you cannot instantiate it.
20    ///
21    /// ## Properties
22    ///
23    ///
24    /// #### `base-stream`
25    ///  The underlying base stream on which the I/O ops will be done.
26    ///
27    /// Readable | Writeable | Construct Only
28    ///
29    ///
30    /// #### `close-base-stream`
31    ///  Whether the base stream should be closed when the filter stream is closed.
32    ///
33    /// Readable | Writeable | Construct
34    ///
35    /// # Implements
36    ///
37    /// [`FilterInputStreamExt`][trait@crate::prelude::FilterInputStreamExt], [`InputStreamExt`][trait@crate::prelude::InputStreamExt], [`trait@glib::ObjectExt`], [`InputStreamExtManual`][trait@crate::prelude::InputStreamExtManual]
38    #[doc(alias = "GFilterInputStream")]
39    pub struct FilterInputStream(Object<ffi::GFilterInputStream, ffi::GFilterInputStreamClass>) @extends InputStream;
40
41    match fn {
42        type_ => || ffi::g_filter_input_stream_get_type(),
43    }
44}
45
46impl FilterInputStream {
47    pub const NONE: Option<&'static FilterInputStream> = None;
48}
49
50mod sealed {
51    pub trait Sealed {}
52    impl<T: super::IsA<super::FilterInputStream>> Sealed for T {}
53}
54
55/// Trait containing all [`struct@FilterInputStream`] methods.
56///
57/// # Implementors
58///
59/// [`BufferedInputStream`][struct@crate::BufferedInputStream], [`ConverterInputStream`][struct@crate::ConverterInputStream], [`FilterInputStream`][struct@crate::FilterInputStream]
60pub trait FilterInputStreamExt: IsA<FilterInputStream> + sealed::Sealed + 'static {
61    /// Gets the base stream for the filter stream.
62    ///
63    /// # Returns
64    ///
65    /// a #GInputStream.
66    #[doc(alias = "g_filter_input_stream_get_base_stream")]
67    #[doc(alias = "get_base_stream")]
68    #[doc(alias = "base-stream")]
69    fn base_stream(&self) -> InputStream {
70        unsafe {
71            from_glib_none(ffi::g_filter_input_stream_get_base_stream(
72                self.as_ref().to_glib_none().0,
73            ))
74        }
75    }
76
77    /// Returns whether the base stream will be closed when @self is
78    /// closed.
79    ///
80    /// # Returns
81    ///
82    /// [`true`] if the base stream will be closed.
83    #[doc(alias = "g_filter_input_stream_get_close_base_stream")]
84    #[doc(alias = "get_close_base_stream")]
85    #[doc(alias = "close-base-stream")]
86    fn closes_base_stream(&self) -> bool {
87        unsafe {
88            from_glib(ffi::g_filter_input_stream_get_close_base_stream(
89                self.as_ref().to_glib_none().0,
90            ))
91        }
92    }
93
94    /// Sets whether the base stream will be closed when @self is closed.
95    /// ## `close_base`
96    /// [`true`] to close the base stream.
97    #[doc(alias = "g_filter_input_stream_set_close_base_stream")]
98    #[doc(alias = "close-base-stream")]
99    fn set_close_base_stream(&self, close_base: bool) {
100        unsafe {
101            ffi::g_filter_input_stream_set_close_base_stream(
102                self.as_ref().to_glib_none().0,
103                close_base.into_glib(),
104            );
105        }
106    }
107
108    #[doc(alias = "close-base-stream")]
109    fn connect_close_base_stream_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
110        unsafe extern "C" fn notify_close_base_stream_trampoline<
111            P: IsA<FilterInputStream>,
112            F: Fn(&P) + 'static,
113        >(
114            this: *mut ffi::GFilterInputStream,
115            _param_spec: glib::ffi::gpointer,
116            f: glib::ffi::gpointer,
117        ) {
118            let f: &F = &*(f as *const F);
119            f(FilterInputStream::from_glib_borrow(this).unsafe_cast_ref())
120        }
121        unsafe {
122            let f: Box_<F> = Box_::new(f);
123            connect_raw(
124                self.as_ptr() as *mut _,
125                b"notify::close-base-stream\0".as_ptr() as *const _,
126                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
127                    notify_close_base_stream_trampoline::<Self, F> as *const (),
128                )),
129                Box_::into_raw(f),
130            )
131        }
132    }
133}
134
135impl<O: IsA<FilterInputStream>> FilterInputStreamExt for O {}