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
// 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! {
    #[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;

    #[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()) }
    }
}

pub trait TlsBackendExt: 'static {
    #[doc(alias = "g_tls_backend_get_certificate_type")]
    #[doc(alias = "get_certificate_type")]
    fn certificate_type(&self) -> glib::types::Type;

    #[doc(alias = "g_tls_backend_get_client_connection_type")]
    #[doc(alias = "get_client_connection_type")]
    fn client_connection_type(&self) -> glib::types::Type;

    #[doc(alias = "g_tls_backend_get_default_database")]
    #[doc(alias = "get_default_database")]
    fn default_database(&self) -> TlsDatabase;

    #[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;

    #[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;

    #[doc(alias = "g_tls_backend_get_file_database_type")]
    #[doc(alias = "get_file_database_type")]
    fn file_database_type(&self) -> glib::types::Type;

    #[doc(alias = "g_tls_backend_get_server_connection_type")]
    #[doc(alias = "get_server_connection_type")]
    fn server_connection_type(&self) -> glib::types::Type;

    #[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>>);

    #[doc(alias = "g_tls_backend_supports_dtls")]
    fn supports_dtls(&self) -> bool;

    #[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")
    }
}