gio/auto/
converter_output_stream.rs1use crate::{ffi, Converter, FilterOutputStream, OutputStream, PollableOutputStream};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 #[doc(alias = "GConverterOutputStream")]
10 pub struct ConverterOutputStream(Object<ffi::GConverterOutputStream, ffi::GConverterOutputStreamClass>) @extends FilterOutputStream, OutputStream, @implements PollableOutputStream;
11
12 match fn {
13 type_ => || ffi::g_converter_output_stream_get_type(),
14 }
15}
16
17impl ConverterOutputStream {
18 pub const NONE: Option<&'static ConverterOutputStream> = None;
19
20 #[doc(alias = "g_converter_output_stream_new")]
21 pub fn new(
22 base_stream: &impl IsA<OutputStream>,
23 converter: &impl IsA<Converter>,
24 ) -> ConverterOutputStream {
25 unsafe {
26 OutputStream::from_glib_full(ffi::g_converter_output_stream_new(
27 base_stream.as_ref().to_glib_none().0,
28 converter.as_ref().to_glib_none().0,
29 ))
30 .unsafe_cast()
31 }
32 }
33
34 pub fn builder() -> ConverterOutputStreamBuilder {
39 ConverterOutputStreamBuilder::new()
40 }
41}
42
43impl Default for ConverterOutputStream {
44 fn default() -> Self {
45 glib::object::Object::new::<Self>()
46 }
47}
48
49#[must_use = "The builder must be built to be used"]
54pub struct ConverterOutputStreamBuilder {
55 builder: glib::object::ObjectBuilder<'static, ConverterOutputStream>,
56}
57
58impl ConverterOutputStreamBuilder {
59 fn new() -> Self {
60 Self {
61 builder: glib::object::Object::builder(),
62 }
63 }
64
65 pub fn converter(self, converter: &impl IsA<Converter>) -> Self {
66 Self {
67 builder: self
68 .builder
69 .property("converter", converter.clone().upcast()),
70 }
71 }
72
73 pub fn base_stream(self, base_stream: &impl IsA<OutputStream>) -> Self {
74 Self {
75 builder: self
76 .builder
77 .property("base-stream", base_stream.clone().upcast()),
78 }
79 }
80
81 pub fn close_base_stream(self, close_base_stream: bool) -> Self {
82 Self {
83 builder: self
84 .builder
85 .property("close-base-stream", close_base_stream),
86 }
87 }
88
89 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
92 pub fn build(self) -> ConverterOutputStream {
93 self.builder.build()
94 }
95}
96
97pub trait ConverterOutputStreamExt: IsA<ConverterOutputStream> + 'static {
98 #[doc(alias = "g_converter_output_stream_get_converter")]
99 #[doc(alias = "get_converter")]
100 fn converter(&self) -> Converter {
101 unsafe {
102 from_glib_none(ffi::g_converter_output_stream_get_converter(
103 self.as_ref().to_glib_none().0,
104 ))
105 }
106 }
107}
108
109impl<O: IsA<ConverterOutputStream>> ConverterOutputStreamExt for O {}