gio/auto/
tcp_wrapper_connection.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi, IOStream, Socket, SocketConnection, TcpConnection};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// A `GTcpWrapperConnection` can be used to wrap a [`IOStream`][crate::IOStream] that is
    /// based on a [`Socket`][crate::Socket], but which is not actually a
    /// [`SocketConnection`][crate::SocketConnection]. This is used by [`SocketClient`][crate::SocketClient] so
    /// that it can always return a [`SocketConnection`][crate::SocketConnection], even when the
    /// connection it has actually created is not directly a
    /// [`SocketConnection`][crate::SocketConnection].
    ///
    /// ## Properties
    ///
    ///
    /// #### `base-io-stream`
    ///  The wrapped [`IOStream`][crate::IOStream].
    ///
    /// Readable | Writeable | Construct Only
    /// <details><summary><h4>TcpConnection</h4></summary>
    ///
    ///
    /// #### `graceful-disconnect`
    ///  Whether [`IOStreamExt::close()`][crate::prelude::IOStreamExt::close()] does a graceful disconnect.
    ///
    /// Readable | Writeable
    /// </details>
    /// <details><summary><h4>SocketConnection</h4></summary>
    ///
    ///
    /// #### `socket`
    ///  The underlying [`Socket`][crate::Socket].
    ///
    /// Readable | Writeable | Construct Only
    /// </details>
    /// <details><summary><h4>IOStream</h4></summary>
    ///
    ///
    /// #### `closed`
    ///  Whether the stream is closed.
    ///
    /// Readable
    ///
    ///
    /// #### `input-stream`
    ///  The [`InputStream`][crate::InputStream] to read from.
    ///
    /// Readable
    ///
    ///
    /// #### `output-stream`
    ///  The [`OutputStream`][crate::OutputStream] to write to.
    ///
    /// Readable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`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]
    #[doc(alias = "GTcpWrapperConnection")]
    pub struct TcpWrapperConnection(Object<ffi::GTcpWrapperConnection, ffi::GTcpWrapperConnectionClass>) @extends TcpConnection, SocketConnection, IOStream;

    match fn {
        type_ => || ffi::g_tcp_wrapper_connection_get_type(),
    }
}

impl TcpWrapperConnection {
    pub const NONE: Option<&'static TcpWrapperConnection> = None;

    /// Wraps @base_io_stream and @socket together as a #GSocketConnection.
    /// ## `base_io_stream`
    /// the #GIOStream to wrap
    /// ## `socket`
    /// the #GSocket associated with @base_io_stream
    ///
    /// # Returns
    ///
    /// the new #GSocketConnection.
    #[doc(alias = "g_tcp_wrapper_connection_new")]
    pub fn new(
        base_io_stream: &impl IsA<IOStream>,
        socket: &impl IsA<Socket>,
    ) -> TcpWrapperConnection {
        unsafe {
            SocketConnection::from_glib_full(ffi::g_tcp_wrapper_connection_new(
                base_io_stream.as_ref().to_glib_none().0,
                socket.as_ref().to_glib_none().0,
            ))
            .unsafe_cast()
        }
    }
}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::TcpWrapperConnection>> Sealed for T {}
}

/// Trait containing all [`struct@TcpWrapperConnection`] methods.
///
/// # Implementors
///
/// [`TcpWrapperConnection`][struct@crate::TcpWrapperConnection]
pub trait TcpWrapperConnectionExt: IsA<TcpWrapperConnection> + sealed::Sealed + 'static {
    /// Gets @self's base #GIOStream
    ///
    /// # Returns
    ///
    /// @self's base #GIOStream
    #[doc(alias = "g_tcp_wrapper_connection_get_base_io_stream")]
    #[doc(alias = "get_base_io_stream")]
    #[doc(alias = "base-io-stream")]
    fn base_io_stream(&self) -> IOStream {
        unsafe {
            from_glib_none(ffi::g_tcp_wrapper_connection_get_base_io_stream(
                self.as_ref().to_glib_none().0,
            ))
        }
    }
}

impl<O: IsA<TcpWrapperConnection>> TcpWrapperConnectionExt for O {}