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
50/// Trait containing all [`struct@FilterOutputStream`] methods.
51///
52/// # Implementors
53///
54/// [`BufferedOutputStream`][struct@crate::BufferedOutputStream], [`ConverterOutputStream`][struct@crate::ConverterOutputStream], [`DataOutputStream`][struct@crate::DataOutputStream], [`FilterOutputStream`][struct@crate::FilterOutputStream]
55pub trait FilterOutputStreamExt: IsA<FilterOutputStream> + 'static {
56 /// Gets the base stream for the filter stream.
57 ///
58 /// # Returns
59 ///
60 /// a [`OutputStream`][crate::OutputStream].
61 #[doc(alias = "g_filter_output_stream_get_base_stream")]
62 #[doc(alias = "get_base_stream")]
63 #[doc(alias = "base-stream")]
64 fn base_stream(&self) -> OutputStream {
65 unsafe {
66 from_glib_none(ffi::g_filter_output_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_output_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_output_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_output_stream_set_close_base_stream")]
93 fn set_close_base_stream(&self, close_base: bool) {
94 unsafe {
95 ffi::g_filter_output_stream_set_close_base_stream(
96 self.as_ref().to_glib_none().0,
97 close_base.into_glib(),
98 );
99 }
100 }
101
102 #[doc(alias = "close-base-stream")]
103 fn connect_close_base_stream_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
104 unsafe extern "C" fn notify_close_base_stream_trampoline<
105 P: IsA<FilterOutputStream>,
106 F: Fn(&P) + 'static,
107 >(
108 this: *mut ffi::GFilterOutputStream,
109 _param_spec: glib::ffi::gpointer,
110 f: glib::ffi::gpointer,
111 ) {
112 let f: &F = &*(f as *const F);
113 f(FilterOutputStream::from_glib_borrow(this).unsafe_cast_ref())
114 }
115 unsafe {
116 let f: Box_<F> = Box_::new(f);
117 connect_raw(
118 self.as_ptr() as *mut _,
119 c"notify::close-base-stream".as_ptr() as *const _,
120 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
121 notify_close_base_stream_trampoline::<Self, F> as *const (),
122 )),
123 Box_::into_raw(f),
124 )
125 }
126 }
127}
128
129impl<O: IsA<FilterOutputStream>> FilterOutputStreamExt for O {}