gio/auto/simple_io_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, IOStream, InputStream, OutputStream};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// `GSimpleIOStream` creates a [`IOStream`][crate::IOStream] from an arbitrary
10 /// [`InputStream`][crate::InputStream] and [`OutputStream`][crate::OutputStream]. This allows any pair of
11 /// input and output streams to be used with [`IOStream`][crate::IOStream] methods.
12 ///
13 /// This is useful when you obtained a [`InputStream`][crate::InputStream] and a
14 /// [`OutputStream`][crate::OutputStream] by other means, for instance creating them with
15 /// platform specific methods as
16 /// [`g_unix_input_stream_new()`](../gio-unix/ctor.UnixInputStream.new.html)
17 /// (from `gio-unix-2.0.pc` / `GioUnix-2.0`), and you want to
18 /// take advantage of the methods provided by [`IOStream`][crate::IOStream].
19 ///
20 /// ## Properties
21 ///
22 ///
23 /// #### `input-stream`
24 /// The [`InputStream`][crate::InputStream] to read from.
25 ///
26 /// Readable | Writeable | Construct Only
27 ///
28 ///
29 /// #### `output-stream`
30 /// The [`OutputStream`][crate::OutputStream] to write to.
31 ///
32 /// Readable | Writeable | Construct Only
33 /// <details><summary><h4>IOStream</h4></summary>
34 ///
35 ///
36 /// #### `closed`
37 /// Whether the stream is closed.
38 ///
39 /// Readable
40 ///
41 ///
42 /// #### `input-stream`
43 /// The [`InputStream`][crate::InputStream] to read from.
44 ///
45 /// Readable
46 ///
47 ///
48 /// #### `output-stream`
49 /// The [`OutputStream`][crate::OutputStream] to write to.
50 ///
51 /// Readable
52 /// </details>
53 ///
54 /// # Implements
55 ///
56 /// [`IOStreamExt`][trait@crate::prelude::IOStreamExt], [`trait@glib::ObjectExt`], [`IOStreamExtManual`][trait@crate::prelude::IOStreamExtManual]
57 #[doc(alias = "GSimpleIOStream")]
58 pub struct SimpleIOStream(Object<ffi::GSimpleIOStream>) @extends IOStream;
59
60 match fn {
61 type_ => || ffi::g_simple_io_stream_get_type(),
62 }
63}
64
65impl SimpleIOStream {
66 /// Creates a new #GSimpleIOStream wrapping @input_stream and @output_stream.
67 /// See also #GIOStream.
68 /// ## `input_stream`
69 /// a #GInputStream.
70 /// ## `output_stream`
71 /// a #GOutputStream.
72 ///
73 /// # Returns
74 ///
75 /// a new #GSimpleIOStream instance.
76 #[doc(alias = "g_simple_io_stream_new")]
77 pub fn new(
78 input_stream: &impl IsA<InputStream>,
79 output_stream: &impl IsA<OutputStream>,
80 ) -> SimpleIOStream {
81 unsafe {
82 IOStream::from_glib_full(ffi::g_simple_io_stream_new(
83 input_stream.as_ref().to_glib_none().0,
84 output_stream.as_ref().to_glib_none().0,
85 ))
86 .unsafe_cast()
87 }
88 }
89}