gio/auto/
filter_output_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, OutputStream};
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 output 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 Only
34    ///
35    /// # Implements
36    ///
37    /// [`FilterOutputStreamExt`][trait@crate::prelude::FilterOutputStreamExt], [`OutputStreamExt`][trait@crate::prelude::OutputStreamExt], [`trait@glib::ObjectExt`], [`OutputStreamExtManual`][trait@crate::prelude::OutputStreamExtManual]
38    #[doc(alias = "GFilterOutputStream")]
39    pub struct FilterOutputStream(Object<ffi::GFilterOutputStream, ffi::GFilterOutputStreamClass>) @extends OutputStream;
40
41    match fn {
42        type_ => || ffi::g_filter_output_stream_get_type(),
43    }
44}
45
46impl FilterOutputStream {
47    pub const NONE: Option<&'static FilterOutputStream> = None;
48}
49
50mod sealed {
51    pub trait Sealed {}
52    impl<T: super::IsA<super::FilterOutputStream>> Sealed for T {}
53}
54
55/// Trait containing all [`struct@FilterOutputStream`] methods.
56///
57/// # Implementors
58///
59/// [`BufferedOutputStream`][struct@crate::BufferedOutputStream], [`ConverterOutputStream`][struct@crate::ConverterOutputStream], [`DataOutputStream`][struct@crate::DataOutputStream], [`FilterOutputStream`][struct@crate::FilterOutputStream]
60pub trait FilterOutputStreamExt: IsA<FilterOutputStream> + sealed::Sealed + 'static {
61    /// Gets the base stream for the filter stream.
62    ///
63    /// # Returns
64    ///
65    /// a [`OutputStream`][crate::OutputStream].
66    #[doc(alias = "g_filter_output_stream_get_base_stream")]
67    #[doc(alias = "get_base_stream")]
68    #[doc(alias = "base-stream")]
69    fn base_stream(&self) -> OutputStream {
70        unsafe {
71            from_glib_none(ffi::g_filter_output_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_output_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_output_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_output_stream_set_close_base_stream")]
98    fn set_close_base_stream(&self, close_base: bool) {
99        unsafe {
100            ffi::g_filter_output_stream_set_close_base_stream(
101                self.as_ref().to_glib_none().0,
102                close_base.into_glib(),
103            );
104        }
105    }
106
107    #[doc(alias = "close-base-stream")]
108    fn connect_close_base_stream_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
109        unsafe extern "C" fn notify_close_base_stream_trampoline<
110            P: IsA<FilterOutputStream>,
111            F: Fn(&P) + 'static,
112        >(
113            this: *mut ffi::GFilterOutputStream,
114            _param_spec: glib::ffi::gpointer,
115            f: glib::ffi::gpointer,
116        ) {
117            let f: &F = &*(f as *const F);
118            f(FilterOutputStream::from_glib_borrow(this).unsafe_cast_ref())
119        }
120        unsafe {
121            let f: Box_<F> = Box_::new(f);
122            connect_raw(
123                self.as_ptr() as *mut _,
124                b"notify::close-base-stream\0".as_ptr() as *const _,
125                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
126                    notify_close_base_stream_trampoline::<Self, F> as *const (),
127                )),
128                Box_::into_raw(f),
129            )
130        }
131    }
132}
133
134impl<O: IsA<FilterOutputStream>> FilterOutputStreamExt for O {}