gio/auto/tls_backend.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, TlsDatabase};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// TLS (Transport Layer Security, aka SSL) and DTLS backend. This is an
10 /// internal type used to coordinate the different classes implemented
11 /// by a TLS backend.
12 ///
13 /// # Implements
14 ///
15 /// [`TlsBackendExt`][trait@crate::prelude::TlsBackendExt]
16 #[doc(alias = "GTlsBackend")]
17 pub struct TlsBackend(Interface<ffi::GTlsBackend, ffi::GTlsBackendInterface>);
18
19 match fn {
20 type_ => || ffi::g_tls_backend_get_type(),
21 }
22}
23
24impl TlsBackend {
25 pub const NONE: Option<&'static TlsBackend> = None;
26
27 /// Gets the default #GTlsBackend for the system.
28 ///
29 /// # Returns
30 ///
31 /// a #GTlsBackend, which will be a
32 /// dummy object if no TLS backend is available
33 #[doc(alias = "g_tls_backend_get_default")]
34 #[doc(alias = "get_default")]
35 #[allow(clippy::should_implement_trait)]
36 pub fn default() -> TlsBackend {
37 unsafe { from_glib_none(ffi::g_tls_backend_get_default()) }
38 }
39}
40
41/// Trait containing all [`struct@TlsBackend`] methods.
42///
43/// # Implementors
44///
45/// [`TlsBackend`][struct@crate::TlsBackend]
46pub trait TlsBackendExt: IsA<TlsBackend> + 'static {
47 /// Gets the #GType of @self's #GTlsCertificate implementation.
48 ///
49 /// # Returns
50 ///
51 /// the #GType of @self's #GTlsCertificate
52 /// implementation.
53 #[doc(alias = "g_tls_backend_get_certificate_type")]
54 #[doc(alias = "get_certificate_type")]
55 fn certificate_type(&self) -> glib::types::Type {
56 unsafe {
57 from_glib(ffi::g_tls_backend_get_certificate_type(
58 self.as_ref().to_glib_none().0,
59 ))
60 }
61 }
62
63 /// Gets the #GType of @self's #GTlsClientConnection implementation.
64 ///
65 /// # Returns
66 ///
67 /// the #GType of @self's #GTlsClientConnection
68 /// implementation.
69 #[doc(alias = "g_tls_backend_get_client_connection_type")]
70 #[doc(alias = "get_client_connection_type")]
71 fn client_connection_type(&self) -> glib::types::Type {
72 unsafe {
73 from_glib(ffi::g_tls_backend_get_client_connection_type(
74 self.as_ref().to_glib_none().0,
75 ))
76 }
77 }
78
79 /// Gets the default #GTlsDatabase used to verify TLS connections.
80 ///
81 /// # Returns
82 ///
83 /// the default database, which should be
84 /// unreffed when done.
85 #[doc(alias = "g_tls_backend_get_default_database")]
86 #[doc(alias = "get_default_database")]
87 fn default_database(&self) -> TlsDatabase {
88 unsafe {
89 from_glib_full(ffi::g_tls_backend_get_default_database(
90 self.as_ref().to_glib_none().0,
91 ))
92 }
93 }
94
95 /// Gets the #GType of @self’s #GDtlsClientConnection implementation.
96 ///
97 /// # Returns
98 ///
99 /// the #GType of @self’s #GDtlsClientConnection
100 /// implementation, or `G_TYPE_INVALID` if this backend doesn’t support DTLS.
101 #[doc(alias = "g_tls_backend_get_dtls_client_connection_type")]
102 #[doc(alias = "get_dtls_client_connection_type")]
103 fn dtls_client_connection_type(&self) -> glib::types::Type {
104 unsafe {
105 from_glib(ffi::g_tls_backend_get_dtls_client_connection_type(
106 self.as_ref().to_glib_none().0,
107 ))
108 }
109 }
110
111 /// Gets the #GType of @self’s #GDtlsServerConnection implementation.
112 ///
113 /// # Returns
114 ///
115 /// the #GType of @self’s #GDtlsServerConnection
116 /// implementation, or `G_TYPE_INVALID` if this backend doesn’t support DTLS.
117 #[doc(alias = "g_tls_backend_get_dtls_server_connection_type")]
118 #[doc(alias = "get_dtls_server_connection_type")]
119 fn dtls_server_connection_type(&self) -> glib::types::Type {
120 unsafe {
121 from_glib(ffi::g_tls_backend_get_dtls_server_connection_type(
122 self.as_ref().to_glib_none().0,
123 ))
124 }
125 }
126
127 /// Gets the #GType of @self's #GTlsFileDatabase implementation.
128 ///
129 /// # Returns
130 ///
131 /// the #GType of backend's #GTlsFileDatabase implementation.
132 #[doc(alias = "g_tls_backend_get_file_database_type")]
133 #[doc(alias = "get_file_database_type")]
134 fn file_database_type(&self) -> glib::types::Type {
135 unsafe {
136 from_glib(ffi::g_tls_backend_get_file_database_type(
137 self.as_ref().to_glib_none().0,
138 ))
139 }
140 }
141
142 /// Gets the #GType of @self's #GTlsServerConnection implementation.
143 ///
144 /// # Returns
145 ///
146 /// the #GType of @self's #GTlsServerConnection
147 /// implementation.
148 #[doc(alias = "g_tls_backend_get_server_connection_type")]
149 #[doc(alias = "get_server_connection_type")]
150 fn server_connection_type(&self) -> glib::types::Type {
151 unsafe {
152 from_glib(ffi::g_tls_backend_get_server_connection_type(
153 self.as_ref().to_glib_none().0,
154 ))
155 }
156 }
157
158 /// Set the default #GTlsDatabase used to verify TLS connections
159 ///
160 /// Any subsequent call to g_tls_backend_get_default_database() will return
161 /// the database set in this call. Existing databases and connections are not
162 /// modified.
163 ///
164 /// Setting a [`None`] default database will reset to using the system default
165 /// database as if g_tls_backend_set_default_database() had never been called.
166 /// ## `database`
167 /// the #GTlsDatabase
168 #[cfg(feature = "v2_60")]
169 #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
170 #[doc(alias = "g_tls_backend_set_default_database")]
171 fn set_default_database(&self, database: Option<&impl IsA<TlsDatabase>>) {
172 unsafe {
173 ffi::g_tls_backend_set_default_database(
174 self.as_ref().to_glib_none().0,
175 database.map(|p| p.as_ref()).to_glib_none().0,
176 );
177 }
178 }
179
180 /// Checks if DTLS is supported. DTLS support may not be available even if TLS
181 /// support is available, and vice-versa.
182 ///
183 /// # Returns
184 ///
185 /// whether DTLS is supported
186 #[doc(alias = "g_tls_backend_supports_dtls")]
187 fn supports_dtls(&self) -> bool {
188 unsafe {
189 from_glib(ffi::g_tls_backend_supports_dtls(
190 self.as_ref().to_glib_none().0,
191 ))
192 }
193 }
194
195 /// Checks if TLS is supported; if this returns [`false`] for the default
196 /// #GTlsBackend, it means no "real" TLS backend is available.
197 ///
198 /// # Returns
199 ///
200 /// whether or not TLS is supported
201 #[doc(alias = "g_tls_backend_supports_tls")]
202 fn supports_tls(&self) -> bool {
203 unsafe {
204 from_glib(ffi::g_tls_backend_supports_tls(
205 self.as_ref().to_glib_none().0,
206 ))
207 }
208 }
209}
210
211impl<O: IsA<TlsBackend>> TlsBackendExt for O {}