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::{TlsDatabase, ffi};
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 /// s #GDtlsClientConnection implementation.
96 ///
97 /// # Returns
98 ///
99 /// t support DTLS.
100 #[doc(alias = "g_tls_backend_get_dtls_client_connection_type")]
101 #[doc(alias = "get_dtls_client_connection_type")]
102 fn dtls_client_connection_type(&self) -> glib::types::Type {
103 unsafe {
104 from_glib(ffi::g_tls_backend_get_dtls_client_connection_type(
105 self.as_ref().to_glib_none().0,
106 ))
107 }
108 }
109
110 /// s #GDtlsServerConnection implementation.
111 ///
112 /// # Returns
113 ///
114 /// t support DTLS.
115 #[doc(alias = "g_tls_backend_get_dtls_server_connection_type")]
116 #[doc(alias = "get_dtls_server_connection_type")]
117 fn dtls_server_connection_type(&self) -> glib::types::Type {
118 unsafe {
119 from_glib(ffi::g_tls_backend_get_dtls_server_connection_type(
120 self.as_ref().to_glib_none().0,
121 ))
122 }
123 }
124
125 /// Gets the #GType of @self's #GTlsFileDatabase implementation.
126 ///
127 /// # Returns
128 ///
129 /// the #GType of backend's #GTlsFileDatabase implementation.
130 #[doc(alias = "g_tls_backend_get_file_database_type")]
131 #[doc(alias = "get_file_database_type")]
132 fn file_database_type(&self) -> glib::types::Type {
133 unsafe {
134 from_glib(ffi::g_tls_backend_get_file_database_type(
135 self.as_ref().to_glib_none().0,
136 ))
137 }
138 }
139
140 /// Gets the #GType of @self's #GTlsServerConnection implementation.
141 ///
142 /// # Returns
143 ///
144 /// the #GType of @self's #GTlsServerConnection
145 /// implementation.
146 #[doc(alias = "g_tls_backend_get_server_connection_type")]
147 #[doc(alias = "get_server_connection_type")]
148 fn server_connection_type(&self) -> glib::types::Type {
149 unsafe {
150 from_glib(ffi::g_tls_backend_get_server_connection_type(
151 self.as_ref().to_glib_none().0,
152 ))
153 }
154 }
155
156 /// Set the default #GTlsDatabase used to verify TLS connections
157 ///
158 /// Any subsequent call to g_tls_backend_get_default_database() will return
159 /// the database set in this call. Existing databases and connections are not
160 /// modified.
161 ///
162 /// Setting a [`None`] default database will reset to using the system default
163 /// database as if g_tls_backend_set_default_database() had never been called.
164 /// ## `database`
165 /// the #GTlsDatabase
166 #[cfg(feature = "v2_60")]
167 #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
168 #[doc(alias = "g_tls_backend_set_default_database")]
169 fn set_default_database(&self, database: Option<&impl IsA<TlsDatabase>>) {
170 unsafe {
171 ffi::g_tls_backend_set_default_database(
172 self.as_ref().to_glib_none().0,
173 database.map(|p| p.as_ref()).to_glib_none().0,
174 );
175 }
176 }
177
178 /// Checks if DTLS is supported. DTLS support may not be available even if TLS
179 /// support is available, and vice-versa.
180 ///
181 /// # Returns
182 ///
183 /// whether DTLS is supported
184 #[doc(alias = "g_tls_backend_supports_dtls")]
185 fn supports_dtls(&self) -> bool {
186 unsafe {
187 from_glib(ffi::g_tls_backend_supports_dtls(
188 self.as_ref().to_glib_none().0,
189 ))
190 }
191 }
192
193 /// Checks if TLS is supported; if this returns [`false`] for the default
194 /// #GTlsBackend, it means no "real" TLS backend is available.
195 ///
196 /// # Returns
197 ///
198 /// whether or not TLS is supported
199 #[doc(alias = "g_tls_backend_supports_tls")]
200 fn supports_tls(&self) -> bool {
201 unsafe {
202 from_glib(ffi::g_tls_backend_supports_tls(
203 self.as_ref().to_glib_none().0,
204 ))
205 }
206 }
207}
208
209impl<O: IsA<TlsBackend>> TlsBackendExt for O {}