gio/auto/
tcp_wrapper_connection.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, Socket, SocketConnection, TcpConnection};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A `GTcpWrapperConnection` can be used to wrap a [`IOStream`][crate::IOStream] that is
10    /// based on a [`Socket`][crate::Socket], but which is not actually a
11    /// [`SocketConnection`][crate::SocketConnection]. This is used by [`SocketClient`][crate::SocketClient] so
12    /// that it can always return a [`SocketConnection`][crate::SocketConnection], even when the
13    /// connection it has actually created is not directly a
14    /// [`SocketConnection`][crate::SocketConnection].
15    ///
16    /// ## Properties
17    ///
18    ///
19    /// #### `base-io-stream`
20    ///  The wrapped [`IOStream`][crate::IOStream].
21    ///
22    /// Readable | Writeable | Construct Only
23    /// <details><summary><h4>TcpConnection</h4></summary>
24    ///
25    ///
26    /// #### `graceful-disconnect`
27    ///  Whether [`IOStreamExt::close()`][crate::prelude::IOStreamExt::close()] does a graceful disconnect.
28    ///
29    /// Readable | Writeable
30    /// </details>
31    /// <details><summary><h4>SocketConnection</h4></summary>
32    ///
33    ///
34    /// #### `socket`
35    ///  The underlying [`Socket`][crate::Socket].
36    ///
37    /// Readable | Writeable | Construct Only
38    /// </details>
39    /// <details><summary><h4>IOStream</h4></summary>
40    ///
41    ///
42    /// #### `closed`
43    ///  Whether the stream is closed.
44    ///
45    /// Readable
46    ///
47    ///
48    /// #### `input-stream`
49    ///  The [`InputStream`][crate::InputStream] to read from.
50    ///
51    /// Readable
52    ///
53    ///
54    /// #### `output-stream`
55    ///  The [`OutputStream`][crate::OutputStream] to write to.
56    ///
57    /// Readable
58    /// </details>
59    ///
60    /// # Implements
61    ///
62    /// [`TcpWrapperConnectionExt`][trait@crate::prelude::TcpWrapperConnectionExt], [`TcpConnectionExt`][trait@crate::prelude::TcpConnectionExt], [`SocketConnectionExt`][trait@crate::prelude::SocketConnectionExt], [`IOStreamExt`][trait@crate::prelude::IOStreamExt], [`trait@glib::ObjectExt`], [`IOStreamExtManual`][trait@crate::prelude::IOStreamExtManual]
63    #[doc(alias = "GTcpWrapperConnection")]
64    pub struct TcpWrapperConnection(Object<ffi::GTcpWrapperConnection, ffi::GTcpWrapperConnectionClass>) @extends TcpConnection, SocketConnection, IOStream;
65
66    match fn {
67        type_ => || ffi::g_tcp_wrapper_connection_get_type(),
68    }
69}
70
71impl TcpWrapperConnection {
72    pub const NONE: Option<&'static TcpWrapperConnection> = None;
73
74    /// Wraps @base_io_stream and @socket together as a #GSocketConnection.
75    /// ## `base_io_stream`
76    /// the #GIOStream to wrap
77    /// ## `socket`
78    /// the #GSocket associated with @base_io_stream
79    ///
80    /// # Returns
81    ///
82    /// the new #GSocketConnection.
83    #[doc(alias = "g_tcp_wrapper_connection_new")]
84    pub fn new(
85        base_io_stream: &impl IsA<IOStream>,
86        socket: &impl IsA<Socket>,
87    ) -> TcpWrapperConnection {
88        unsafe {
89            SocketConnection::from_glib_full(ffi::g_tcp_wrapper_connection_new(
90                base_io_stream.as_ref().to_glib_none().0,
91                socket.as_ref().to_glib_none().0,
92            ))
93            .unsafe_cast()
94        }
95    }
96}
97
98mod sealed {
99    pub trait Sealed {}
100    impl<T: super::IsA<super::TcpWrapperConnection>> Sealed for T {}
101}
102
103/// Trait containing all [`struct@TcpWrapperConnection`] methods.
104///
105/// # Implementors
106///
107/// [`TcpWrapperConnection`][struct@crate::TcpWrapperConnection]
108pub trait TcpWrapperConnectionExt: IsA<TcpWrapperConnection> + sealed::Sealed + 'static {
109    /// Gets @self's base #GIOStream
110    ///
111    /// # Returns
112    ///
113    /// @self's base #GIOStream
114    #[doc(alias = "g_tcp_wrapper_connection_get_base_io_stream")]
115    #[doc(alias = "get_base_io_stream")]
116    #[doc(alias = "base-io-stream")]
117    fn base_io_stream(&self) -> IOStream {
118        unsafe {
119            from_glib_none(ffi::g_tcp_wrapper_connection_get_base_io_stream(
120                self.as_ref().to_glib_none().0,
121            ))
122        }
123    }
124}
125
126impl<O: IsA<TcpWrapperConnection>> TcpWrapperConnectionExt for O {}