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