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
50/// Trait containing all [`struct@FilterInputStream`] methods.
51///
52/// # Implementors
53///
54/// [`BufferedInputStream`][struct@crate::BufferedInputStream], [`ConverterInputStream`][struct@crate::ConverterInputStream], [`FilterInputStream`][struct@crate::FilterInputStream]
55pub trait FilterInputStreamExt: IsA<FilterInputStream> + 'static {
56    /// Gets the base stream for the filter stream.
57    ///
58    /// # Returns
59    ///
60    /// a #GInputStream.
61    #[doc(alias = "g_filter_input_stream_get_base_stream")]
62    #[doc(alias = "get_base_stream")]
63    #[doc(alias = "base-stream")]
64    fn base_stream(&self) -> InputStream {
65        unsafe {
66            from_glib_none(ffi::g_filter_input_stream_get_base_stream(
67                self.as_ref().to_glib_none().0,
68            ))
69        }
70    }
71
72    /// Returns whether the base stream will be closed when @self is
73    /// closed.
74    ///
75    /// # Returns
76    ///
77    /// [`true`] if the base stream will be closed.
78    #[doc(alias = "g_filter_input_stream_get_close_base_stream")]
79    #[doc(alias = "get_close_base_stream")]
80    #[doc(alias = "close-base-stream")]
81    fn closes_base_stream(&self) -> bool {
82        unsafe {
83            from_glib(ffi::g_filter_input_stream_get_close_base_stream(
84                self.as_ref().to_glib_none().0,
85            ))
86        }
87    }
88
89    /// Sets whether the base stream will be closed when @self is closed.
90    /// ## `close_base`
91    /// [`true`] to close the base stream.
92    #[doc(alias = "g_filter_input_stream_set_close_base_stream")]
93    #[doc(alias = "close-base-stream")]
94    fn set_close_base_stream(&self, close_base: bool) {
95        unsafe {
96            ffi::g_filter_input_stream_set_close_base_stream(
97                self.as_ref().to_glib_none().0,
98                close_base.into_glib(),
99            );
100        }
101    }
102
103    #[doc(alias = "close-base-stream")]
104    fn connect_close_base_stream_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
105        unsafe extern "C" fn notify_close_base_stream_trampoline<
106            P: IsA<FilterInputStream>,
107            F: Fn(&P) + 'static,
108        >(
109            this: *mut ffi::GFilterInputStream,
110            _param_spec: glib::ffi::gpointer,
111            f: glib::ffi::gpointer,
112        ) {
113            let f: &F = &*(f as *const F);
114            f(FilterInputStream::from_glib_borrow(this).unsafe_cast_ref())
115        }
116        unsafe {
117            let f: Box_<F> = Box_::new(f);
118            connect_raw(
119                self.as_ptr() as *mut _,
120                c"notify::close-base-stream".as_ptr() as *const _,
121                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
122                    notify_close_base_stream_trampoline::<Self, F> as *const (),
123                )),
124                Box_::into_raw(f),
125            )
126        }
127    }
128}
129
130impl<O: IsA<FilterInputStream>> FilterInputStreamExt for O {}