gio/auto/
converter_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, Converter, FilterOutputStream, OutputStream, PollableOutputStream};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// Converter output stream implements [`OutputStream`][crate::OutputStream] and allows
10    /// conversion of data of various types during reading.
11    ///
12    /// As of GLib 2.34, `GConverterOutputStream` implements
13    /// [`PollableOutputStream`][crate::PollableOutputStream].
14    ///
15    /// ## Properties
16    ///
17    ///
18    /// #### `converter`
19    ///  The converter object.
20    ///
21    /// Readable | Writeable | Construct Only
22    /// <details><summary><h4>FilterOutputStream</h4></summary>
23    ///
24    ///
25    /// #### `base-stream`
26    ///  The underlying base stream on which the I/O ops will be done.
27    ///
28    /// Readable | Writeable | Construct Only
29    ///
30    ///
31    /// #### `close-base-stream`
32    ///  Whether the base stream should be closed when the filter stream is closed.
33    ///
34    /// Readable | Writeable | Construct Only
35    /// </details>
36    ///
37    /// # Implements
38    ///
39    /// [`ConverterOutputStreamExt`][trait@crate::prelude::ConverterOutputStreamExt], [`FilterOutputStreamExt`][trait@crate::prelude::FilterOutputStreamExt], [`OutputStreamExt`][trait@crate::prelude::OutputStreamExt], [`trait@glib::ObjectExt`], [`PollableOutputStreamExt`][trait@crate::prelude::PollableOutputStreamExt], [`OutputStreamExtManual`][trait@crate::prelude::OutputStreamExtManual], [`PollableOutputStreamExtManual`][trait@crate::prelude::PollableOutputStreamExtManual]
40    #[doc(alias = "GConverterOutputStream")]
41    pub struct ConverterOutputStream(Object<ffi::GConverterOutputStream, ffi::GConverterOutputStreamClass>) @extends FilterOutputStream, OutputStream, @implements PollableOutputStream;
42
43    match fn {
44        type_ => || ffi::g_converter_output_stream_get_type(),
45    }
46}
47
48impl ConverterOutputStream {
49    pub const NONE: Option<&'static ConverterOutputStream> = None;
50
51    /// Creates a new converter output stream for the @base_stream.
52    /// ## `base_stream`
53    /// a #GOutputStream
54    /// ## `converter`
55    /// a #GConverter
56    ///
57    /// # Returns
58    ///
59    /// a new #GOutputStream.
60    #[doc(alias = "g_converter_output_stream_new")]
61    pub fn new(
62        base_stream: &impl IsA<OutputStream>,
63        converter: &impl IsA<Converter>,
64    ) -> ConverterOutputStream {
65        unsafe {
66            OutputStream::from_glib_full(ffi::g_converter_output_stream_new(
67                base_stream.as_ref().to_glib_none().0,
68                converter.as_ref().to_glib_none().0,
69            ))
70            .unsafe_cast()
71        }
72    }
73
74    // rustdoc-stripper-ignore-next
75    /// Creates a new builder-pattern struct instance to construct [`ConverterOutputStream`] objects.
76    ///
77    /// This method returns an instance of [`ConverterOutputStreamBuilder`](crate::builders::ConverterOutputStreamBuilder) which can be used to create [`ConverterOutputStream`] objects.
78    pub fn builder() -> ConverterOutputStreamBuilder {
79        ConverterOutputStreamBuilder::new()
80    }
81}
82
83impl Default for ConverterOutputStream {
84    fn default() -> Self {
85        glib::object::Object::new::<Self>()
86    }
87}
88
89// rustdoc-stripper-ignore-next
90/// A [builder-pattern] type to construct [`ConverterOutputStream`] objects.
91///
92/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
93#[must_use = "The builder must be built to be used"]
94pub struct ConverterOutputStreamBuilder {
95    builder: glib::object::ObjectBuilder<'static, ConverterOutputStream>,
96}
97
98impl ConverterOutputStreamBuilder {
99    fn new() -> Self {
100        Self {
101            builder: glib::object::Object::builder(),
102        }
103    }
104
105    /// The converter object.
106    pub fn converter(self, converter: &impl IsA<Converter>) -> Self {
107        Self {
108            builder: self
109                .builder
110                .property("converter", converter.clone().upcast()),
111        }
112    }
113
114    /// The underlying base stream on which the I/O ops will be done.
115    pub fn base_stream(self, base_stream: &impl IsA<OutputStream>) -> Self {
116        Self {
117            builder: self
118                .builder
119                .property("base-stream", base_stream.clone().upcast()),
120        }
121    }
122
123    /// Whether the base stream should be closed when the filter stream is closed.
124    pub fn close_base_stream(self, close_base_stream: bool) -> Self {
125        Self {
126            builder: self
127                .builder
128                .property("close-base-stream", close_base_stream),
129        }
130    }
131
132    // rustdoc-stripper-ignore-next
133    /// Build the [`ConverterOutputStream`].
134    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
135    pub fn build(self) -> ConverterOutputStream {
136        self.builder.build()
137    }
138}
139
140mod sealed {
141    pub trait Sealed {}
142    impl<T: super::IsA<super::ConverterOutputStream>> Sealed for T {}
143}
144
145/// Trait containing all [`struct@ConverterOutputStream`] methods.
146///
147/// # Implementors
148///
149/// [`ConverterOutputStream`][struct@crate::ConverterOutputStream]
150pub trait ConverterOutputStreamExt: IsA<ConverterOutputStream> + sealed::Sealed + 'static {
151    /// Gets the #GConverter that is used by @self.
152    ///
153    /// # Returns
154    ///
155    /// the converter of the converter output stream
156    #[doc(alias = "g_converter_output_stream_get_converter")]
157    #[doc(alias = "get_converter")]
158    fn converter(&self) -> Converter {
159        unsafe {
160            from_glib_none(ffi::g_converter_output_stream_get_converter(
161                self.as_ref().to_glib_none().0,
162            ))
163        }
164    }
165}
166
167impl<O: IsA<ConverterOutputStream>> ConverterOutputStreamExt for O {}