gio/auto/
tls_backend.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// 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, TlsDatabase};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// TLS (Transport Layer Security, aka SSL) and DTLS backend. This is an
    /// internal type used to coordinate the different classes implemented
    /// by a TLS backend.
    ///
    /// # Implements
    ///
    /// [`TlsBackendExt`][trait@crate::prelude::TlsBackendExt]
    #[doc(alias = "GTlsBackend")]
    pub struct TlsBackend(Interface<ffi::GTlsBackend, ffi::GTlsBackendInterface>);

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

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

    /// Gets the default #GTlsBackend for the system.
    ///
    /// # Returns
    ///
    /// a #GTlsBackend, which will be a
    ///     dummy object if no TLS backend is available
    #[doc(alias = "g_tls_backend_get_default")]
    #[doc(alias = "get_default")]
    #[allow(clippy::should_implement_trait)]
    pub fn default() -> TlsBackend {
        unsafe { from_glib_none(ffi::g_tls_backend_get_default()) }
    }
}

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

/// Trait containing all [`struct@TlsBackend`] methods.
///
/// # Implementors
///
/// [`TlsBackend`][struct@crate::TlsBackend]
pub trait TlsBackendExt: IsA<TlsBackend> + sealed::Sealed + 'static {
    /// Gets the #GType of @self's #GTlsCertificate implementation.
    ///
    /// # Returns
    ///
    /// the #GType of @self's #GTlsCertificate
    ///   implementation.
    #[doc(alias = "g_tls_backend_get_certificate_type")]
    #[doc(alias = "get_certificate_type")]
    fn certificate_type(&self) -> glib::types::Type {
        unsafe {
            from_glib(ffi::g_tls_backend_get_certificate_type(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets the #GType of @self's #GTlsClientConnection implementation.
    ///
    /// # Returns
    ///
    /// the #GType of @self's #GTlsClientConnection
    ///   implementation.
    #[doc(alias = "g_tls_backend_get_client_connection_type")]
    #[doc(alias = "get_client_connection_type")]
    fn client_connection_type(&self) -> glib::types::Type {
        unsafe {
            from_glib(ffi::g_tls_backend_get_client_connection_type(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets the default #GTlsDatabase used to verify TLS connections.
    ///
    /// # Returns
    ///
    /// the default database, which should be
    ///               unreffed when done.
    #[doc(alias = "g_tls_backend_get_default_database")]
    #[doc(alias = "get_default_database")]
    fn default_database(&self) -> TlsDatabase {
        unsafe {
            from_glib_full(ffi::g_tls_backend_get_default_database(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets the #GType of @self’s #GDtlsClientConnection implementation.
    ///
    /// # Returns
    ///
    /// the #GType of @self’s #GDtlsClientConnection
    ///   implementation, or `G_TYPE_INVALID` if this backend doesn’t support DTLS.
    #[doc(alias = "g_tls_backend_get_dtls_client_connection_type")]
    #[doc(alias = "get_dtls_client_connection_type")]
    fn dtls_client_connection_type(&self) -> glib::types::Type {
        unsafe {
            from_glib(ffi::g_tls_backend_get_dtls_client_connection_type(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets the #GType of @self’s #GDtlsServerConnection implementation.
    ///
    /// # Returns
    ///
    /// the #GType of @self’s #GDtlsServerConnection
    ///   implementation, or `G_TYPE_INVALID` if this backend doesn’t support DTLS.
    #[doc(alias = "g_tls_backend_get_dtls_server_connection_type")]
    #[doc(alias = "get_dtls_server_connection_type")]
    fn dtls_server_connection_type(&self) -> glib::types::Type {
        unsafe {
            from_glib(ffi::g_tls_backend_get_dtls_server_connection_type(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets the #GType of @self's #GTlsFileDatabase implementation.
    ///
    /// # Returns
    ///
    /// the #GType of backend's #GTlsFileDatabase implementation.
    #[doc(alias = "g_tls_backend_get_file_database_type")]
    #[doc(alias = "get_file_database_type")]
    fn file_database_type(&self) -> glib::types::Type {
        unsafe {
            from_glib(ffi::g_tls_backend_get_file_database_type(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Gets the #GType of @self's #GTlsServerConnection implementation.
    ///
    /// # Returns
    ///
    /// the #GType of @self's #GTlsServerConnection
    ///   implementation.
    #[doc(alias = "g_tls_backend_get_server_connection_type")]
    #[doc(alias = "get_server_connection_type")]
    fn server_connection_type(&self) -> glib::types::Type {
        unsafe {
            from_glib(ffi::g_tls_backend_get_server_connection_type(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Set the default #GTlsDatabase used to verify TLS connections
    ///
    /// Any subsequent call to g_tls_backend_get_default_database() will return
    /// the database set in this call.  Existing databases and connections are not
    /// modified.
    ///
    /// Setting a [`None`] default database will reset to using the system default
    /// database as if g_tls_backend_set_default_database() had never been called.
    /// ## `database`
    /// the #GTlsDatabase
    #[cfg(feature = "v2_60")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
    #[doc(alias = "g_tls_backend_set_default_database")]
    fn set_default_database(&self, database: Option<&impl IsA<TlsDatabase>>) {
        unsafe {
            ffi::g_tls_backend_set_default_database(
                self.as_ref().to_glib_none().0,
                database.map(|p| p.as_ref()).to_glib_none().0,
            );
        }
    }

    /// Checks if DTLS is supported. DTLS support may not be available even if TLS
    /// support is available, and vice-versa.
    ///
    /// # Returns
    ///
    /// whether DTLS is supported
    #[doc(alias = "g_tls_backend_supports_dtls")]
    fn supports_dtls(&self) -> bool {
        unsafe {
            from_glib(ffi::g_tls_backend_supports_dtls(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Checks if TLS is supported; if this returns [`false`] for the default
    /// #GTlsBackend, it means no "real" TLS backend is available.
    ///
    /// # Returns
    ///
    /// whether or not TLS is supported
    #[doc(alias = "g_tls_backend_supports_tls")]
    fn supports_tls(&self) -> bool {
        unsafe {
            from_glib(ffi::g_tls_backend_supports_tls(
                self.as_ref().to_glib_none().0,
            ))
        }
    }
}

impl<O: IsA<TlsBackend>> TlsBackendExt for O {}