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 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
// 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::TlsDatabase;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
/// TLS (Transport Layer Security, aka SSL) and DTLS 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 [`TlsBackend`][crate::TlsBackend] for the system.
///
/// # Returns
///
/// a [`TlsBackend`][crate::TlsBackend], 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()) }
}
}
/// Trait containing all [`struct@TlsBackend`] methods.
///
/// # Implementors
///
/// [`TlsBackend`][struct@crate::TlsBackend]
pub trait TlsBackendExt: 'static {
/// Gets the `GType` of `self`'s [`TlsCertificate`][crate::TlsCertificate] implementation.
///
/// # Returns
///
/// the `GType` of `self`'s [`TlsCertificate`][crate::TlsCertificate]
/// implementation.
#[doc(alias = "g_tls_backend_get_certificate_type")]
#[doc(alias = "get_certificate_type")]
fn certificate_type(&self) -> glib::types::Type;
/// Gets the `GType` of `self`'s [`TlsClientConnection`][crate::TlsClientConnection] implementation.
///
/// # Returns
///
/// the `GType` of `self`'s [`TlsClientConnection`][crate::TlsClientConnection]
/// implementation.
#[doc(alias = "g_tls_backend_get_client_connection_type")]
#[doc(alias = "get_client_connection_type")]
fn client_connection_type(&self) -> glib::types::Type;
/// Gets the default [`TlsDatabase`][crate::TlsDatabase] 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;
/// 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;
/// 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;
/// Gets the `GType` of `self`'s [`TlsFileDatabase`][crate::TlsFileDatabase] implementation.
///
/// # Returns
///
/// the `GType` of backend's [`TlsFileDatabase`][crate::TlsFileDatabase] implementation.
#[doc(alias = "g_tls_backend_get_file_database_type")]
#[doc(alias = "get_file_database_type")]
fn file_database_type(&self) -> glib::types::Type;
/// Gets the `GType` of `self`'s [`TlsServerConnection`][crate::TlsServerConnection] implementation.
///
/// # Returns
///
/// the `GType` of `self`'s [`TlsServerConnection`][crate::TlsServerConnection]
/// implementation.
#[doc(alias = "g_tls_backend_get_server_connection_type")]
#[doc(alias = "get_server_connection_type")]
fn server_connection_type(&self) -> glib::types::Type;
/// Set the default [`TlsDatabase`][crate::TlsDatabase] used to verify TLS connections
///
/// Any subsequent call to [`default_database()`][Self::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 [`set_default_database()`][Self::set_default_database()] had never been called.
/// ## `database`
/// the [`TlsDatabase`][crate::TlsDatabase]
#[cfg(any(feature = "v2_60", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
#[doc(alias = "g_tls_backend_set_default_database")]
fn set_default_database(&self, database: Option<&impl IsA<TlsDatabase>>);
/// 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;
/// Checks if TLS is supported; if this returns [`false`] for the default
/// [`TlsBackend`][crate::TlsBackend], 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;
}
impl<O: IsA<TlsBackend>> TlsBackendExt for O {
fn certificate_type(&self) -> glib::types::Type {
unsafe {
from_glib(ffi::g_tls_backend_get_certificate_type(
self.as_ref().to_glib_none().0,
))
}
}
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,
))
}
}
fn default_database(&self) -> TlsDatabase {
unsafe {
from_glib_full(ffi::g_tls_backend_get_default_database(
self.as_ref().to_glib_none().0,
))
}
}
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,
))
}
}
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,
))
}
}
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,
))
}
}
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,
))
}
}
#[cfg(any(feature = "v2_60", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))]
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,
);
}
}
fn supports_dtls(&self) -> bool {
unsafe {
from_glib(ffi::g_tls_backend_supports_dtls(
self.as_ref().to_glib_none().0,
))
}
}
fn supports_tls(&self) -> bool {
unsafe {
from_glib(ffi::g_tls_backend_supports_tls(
self.as_ref().to_glib_none().0,
))
}
}
}
impl fmt::Display for TlsBackend {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("TlsBackend")
}
}