gio/auto/
tls_connection.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#![allow(deprecated)]
5
6#[cfg(feature = "v2_70")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
8use crate::TlsProtocolVersion;
9use crate::{
10    ffi, AsyncResult, Cancellable, IOStream, TlsCertificate, TlsCertificateFlags, TlsDatabase,
11    TlsInteraction, TlsRehandshakeMode,
12};
13use glib::{
14    object::ObjectType as _,
15    prelude::*,
16    signal::{connect_raw, SignalHandlerId},
17    translate::*,
18};
19use std::{boxed::Box as Box_, pin::Pin};
20
21glib::wrapper! {
22    #[doc(alias = "GTlsConnection")]
23    pub struct TlsConnection(Object<ffi::GTlsConnection, ffi::GTlsConnectionClass>) @extends IOStream;
24
25    match fn {
26        type_ => || ffi::g_tls_connection_get_type(),
27    }
28}
29
30impl TlsConnection {
31    pub const NONE: Option<&'static TlsConnection> = None;
32}
33
34pub trait TlsConnectionExt: IsA<TlsConnection> + 'static {
35    #[doc(alias = "g_tls_connection_emit_accept_certificate")]
36    fn emit_accept_certificate(
37        &self,
38        peer_cert: &impl IsA<TlsCertificate>,
39        errors: TlsCertificateFlags,
40    ) -> bool {
41        unsafe {
42            from_glib(ffi::g_tls_connection_emit_accept_certificate(
43                self.as_ref().to_glib_none().0,
44                peer_cert.as_ref().to_glib_none().0,
45                errors.into_glib(),
46            ))
47        }
48    }
49
50    #[doc(alias = "g_tls_connection_get_certificate")]
51    #[doc(alias = "get_certificate")]
52    fn certificate(&self) -> Option<TlsCertificate> {
53        unsafe {
54            from_glib_none(ffi::g_tls_connection_get_certificate(
55                self.as_ref().to_glib_none().0,
56            ))
57        }
58    }
59
60    #[cfg(feature = "v2_70")]
61    #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
62    #[doc(alias = "g_tls_connection_get_ciphersuite_name")]
63    #[doc(alias = "get_ciphersuite_name")]
64    #[doc(alias = "ciphersuite-name")]
65    fn ciphersuite_name(&self) -> Option<glib::GString> {
66        unsafe {
67            from_glib_full(ffi::g_tls_connection_get_ciphersuite_name(
68                self.as_ref().to_glib_none().0,
69            ))
70        }
71    }
72
73    #[doc(alias = "g_tls_connection_get_database")]
74    #[doc(alias = "get_database")]
75    fn database(&self) -> Option<TlsDatabase> {
76        unsafe {
77            from_glib_none(ffi::g_tls_connection_get_database(
78                self.as_ref().to_glib_none().0,
79            ))
80        }
81    }
82
83    #[doc(alias = "g_tls_connection_get_interaction")]
84    #[doc(alias = "get_interaction")]
85    fn interaction(&self) -> Option<TlsInteraction> {
86        unsafe {
87            from_glib_none(ffi::g_tls_connection_get_interaction(
88                self.as_ref().to_glib_none().0,
89            ))
90        }
91    }
92
93    #[cfg(feature = "v2_60")]
94    #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
95    #[doc(alias = "g_tls_connection_get_negotiated_protocol")]
96    #[doc(alias = "get_negotiated_protocol")]
97    #[doc(alias = "negotiated-protocol")]
98    fn negotiated_protocol(&self) -> Option<glib::GString> {
99        unsafe {
100            from_glib_none(ffi::g_tls_connection_get_negotiated_protocol(
101                self.as_ref().to_glib_none().0,
102            ))
103        }
104    }
105
106    #[doc(alias = "g_tls_connection_get_peer_certificate")]
107    #[doc(alias = "get_peer_certificate")]
108    #[doc(alias = "peer-certificate")]
109    fn peer_certificate(&self) -> Option<TlsCertificate> {
110        unsafe {
111            from_glib_none(ffi::g_tls_connection_get_peer_certificate(
112                self.as_ref().to_glib_none().0,
113            ))
114        }
115    }
116
117    #[doc(alias = "g_tls_connection_get_peer_certificate_errors")]
118    #[doc(alias = "get_peer_certificate_errors")]
119    #[doc(alias = "peer-certificate-errors")]
120    fn peer_certificate_errors(&self) -> TlsCertificateFlags {
121        unsafe {
122            from_glib(ffi::g_tls_connection_get_peer_certificate_errors(
123                self.as_ref().to_glib_none().0,
124            ))
125        }
126    }
127
128    #[cfg(feature = "v2_70")]
129    #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
130    #[doc(alias = "g_tls_connection_get_protocol_version")]
131    #[doc(alias = "get_protocol_version")]
132    #[doc(alias = "protocol-version")]
133    fn protocol_version(&self) -> TlsProtocolVersion {
134        unsafe {
135            from_glib(ffi::g_tls_connection_get_protocol_version(
136                self.as_ref().to_glib_none().0,
137            ))
138        }
139    }
140
141    #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")]
142    #[allow(deprecated)]
143    #[doc(alias = "g_tls_connection_get_rehandshake_mode")]
144    #[doc(alias = "get_rehandshake_mode")]
145    #[doc(alias = "rehandshake-mode")]
146    fn rehandshake_mode(&self) -> TlsRehandshakeMode {
147        unsafe {
148            from_glib(ffi::g_tls_connection_get_rehandshake_mode(
149                self.as_ref().to_glib_none().0,
150            ))
151        }
152    }
153
154    #[doc(alias = "g_tls_connection_get_require_close_notify")]
155    #[doc(alias = "get_require_close_notify")]
156    #[doc(alias = "require-close-notify")]
157    fn requires_close_notify(&self) -> bool {
158        unsafe {
159            from_glib(ffi::g_tls_connection_get_require_close_notify(
160                self.as_ref().to_glib_none().0,
161            ))
162        }
163    }
164
165    #[doc(alias = "g_tls_connection_handshake")]
166    fn handshake(&self, cancellable: Option<&impl IsA<Cancellable>>) -> Result<(), glib::Error> {
167        unsafe {
168            let mut error = std::ptr::null_mut();
169            let is_ok = ffi::g_tls_connection_handshake(
170                self.as_ref().to_glib_none().0,
171                cancellable.map(|p| p.as_ref()).to_glib_none().0,
172                &mut error,
173            );
174            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
175            if error.is_null() {
176                Ok(())
177            } else {
178                Err(from_glib_full(error))
179            }
180        }
181    }
182
183    #[doc(alias = "g_tls_connection_handshake_async")]
184    fn handshake_async<P: FnOnce(Result<(), glib::Error>) + 'static>(
185        &self,
186        io_priority: glib::Priority,
187        cancellable: Option<&impl IsA<Cancellable>>,
188        callback: P,
189    ) {
190        let main_context = glib::MainContext::ref_thread_default();
191        let is_main_context_owner = main_context.is_owner();
192        let has_acquired_main_context = (!is_main_context_owner)
193            .then(|| main_context.acquire().ok())
194            .flatten();
195        assert!(
196            is_main_context_owner || has_acquired_main_context.is_some(),
197            "Async operations only allowed if the thread is owning the MainContext"
198        );
199
200        let user_data: Box_<glib::thread_guard::ThreadGuard<P>> =
201            Box_::new(glib::thread_guard::ThreadGuard::new(callback));
202        unsafe extern "C" fn handshake_async_trampoline<
203            P: FnOnce(Result<(), glib::Error>) + 'static,
204        >(
205            _source_object: *mut glib::gobject_ffi::GObject,
206            res: *mut crate::ffi::GAsyncResult,
207            user_data: glib::ffi::gpointer,
208        ) {
209            let mut error = std::ptr::null_mut();
210            ffi::g_tls_connection_handshake_finish(_source_object as *mut _, res, &mut error);
211            let result = if error.is_null() {
212                Ok(())
213            } else {
214                Err(from_glib_full(error))
215            };
216            let callback: Box_<glib::thread_guard::ThreadGuard<P>> =
217                Box_::from_raw(user_data as *mut _);
218            let callback: P = callback.into_inner();
219            callback(result);
220        }
221        let callback = handshake_async_trampoline::<P>;
222        unsafe {
223            ffi::g_tls_connection_handshake_async(
224                self.as_ref().to_glib_none().0,
225                io_priority.into_glib(),
226                cancellable.map(|p| p.as_ref()).to_glib_none().0,
227                Some(callback),
228                Box_::into_raw(user_data) as *mut _,
229            );
230        }
231    }
232
233    fn handshake_future(
234        &self,
235        io_priority: glib::Priority,
236    ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> {
237        Box_::pin(crate::GioFuture::new(
238            self,
239            move |obj, cancellable, send| {
240                obj.handshake_async(io_priority, Some(cancellable), move |res| {
241                    send.resolve(res);
242                });
243            },
244        ))
245    }
246
247    #[doc(alias = "g_tls_connection_set_certificate")]
248    #[doc(alias = "certificate")]
249    fn set_certificate(&self, certificate: &impl IsA<TlsCertificate>) {
250        unsafe {
251            ffi::g_tls_connection_set_certificate(
252                self.as_ref().to_glib_none().0,
253                certificate.as_ref().to_glib_none().0,
254            );
255        }
256    }
257
258    #[doc(alias = "g_tls_connection_set_database")]
259    #[doc(alias = "database")]
260    fn set_database(&self, database: Option<&impl IsA<TlsDatabase>>) {
261        unsafe {
262            ffi::g_tls_connection_set_database(
263                self.as_ref().to_glib_none().0,
264                database.map(|p| p.as_ref()).to_glib_none().0,
265            );
266        }
267    }
268
269    #[doc(alias = "g_tls_connection_set_interaction")]
270    #[doc(alias = "interaction")]
271    fn set_interaction(&self, interaction: Option<&impl IsA<TlsInteraction>>) {
272        unsafe {
273            ffi::g_tls_connection_set_interaction(
274                self.as_ref().to_glib_none().0,
275                interaction.map(|p| p.as_ref()).to_glib_none().0,
276            );
277        }
278    }
279
280    #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")]
281    #[allow(deprecated)]
282    #[doc(alias = "g_tls_connection_set_rehandshake_mode")]
283    #[doc(alias = "rehandshake-mode")]
284    fn set_rehandshake_mode(&self, mode: TlsRehandshakeMode) {
285        unsafe {
286            ffi::g_tls_connection_set_rehandshake_mode(
287                self.as_ref().to_glib_none().0,
288                mode.into_glib(),
289            );
290        }
291    }
292
293    #[doc(alias = "g_tls_connection_set_require_close_notify")]
294    #[doc(alias = "require-close-notify")]
295    fn set_require_close_notify(&self, require_close_notify: bool) {
296        unsafe {
297            ffi::g_tls_connection_set_require_close_notify(
298                self.as_ref().to_glib_none().0,
299                require_close_notify.into_glib(),
300            );
301        }
302    }
303
304    #[cfg(feature = "v2_60")]
305    #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
306    #[doc(alias = "advertised-protocols")]
307    fn advertised_protocols(&self) -> Vec<glib::GString> {
308        ObjectExt::property(self.as_ref(), "advertised-protocols")
309    }
310
311    #[doc(alias = "base-io-stream")]
312    fn base_io_stream(&self) -> Option<IOStream> {
313        ObjectExt::property(self.as_ref(), "base-io-stream")
314    }
315
316    #[doc(alias = "accept-certificate")]
317    fn connect_accept_certificate<
318        F: Fn(&Self, &TlsCertificate, TlsCertificateFlags) -> bool + 'static,
319    >(
320        &self,
321        f: F,
322    ) -> SignalHandlerId {
323        unsafe extern "C" fn accept_certificate_trampoline<
324            P: IsA<TlsConnection>,
325            F: Fn(&P, &TlsCertificate, TlsCertificateFlags) -> bool + 'static,
326        >(
327            this: *mut ffi::GTlsConnection,
328            peer_cert: *mut ffi::GTlsCertificate,
329            errors: ffi::GTlsCertificateFlags,
330            f: glib::ffi::gpointer,
331        ) -> glib::ffi::gboolean {
332            let f: &F = &*(f as *const F);
333            f(
334                TlsConnection::from_glib_borrow(this).unsafe_cast_ref(),
335                &from_glib_borrow(peer_cert),
336                from_glib(errors),
337            )
338            .into_glib()
339        }
340        unsafe {
341            let f: Box_<F> = Box_::new(f);
342            connect_raw(
343                self.as_ptr() as *mut _,
344                c"accept-certificate".as_ptr() as *const _,
345                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
346                    accept_certificate_trampoline::<Self, F> as *const (),
347                )),
348                Box_::into_raw(f),
349            )
350        }
351    }
352
353    #[cfg(feature = "v2_60")]
354    #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
355    #[doc(alias = "advertised-protocols")]
356    fn connect_advertised_protocols_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
357        unsafe extern "C" fn notify_advertised_protocols_trampoline<
358            P: IsA<TlsConnection>,
359            F: Fn(&P) + 'static,
360        >(
361            this: *mut ffi::GTlsConnection,
362            _param_spec: glib::ffi::gpointer,
363            f: glib::ffi::gpointer,
364        ) {
365            let f: &F = &*(f as *const F);
366            f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref())
367        }
368        unsafe {
369            let f: Box_<F> = Box_::new(f);
370            connect_raw(
371                self.as_ptr() as *mut _,
372                c"notify::advertised-protocols".as_ptr() as *const _,
373                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
374                    notify_advertised_protocols_trampoline::<Self, F> as *const (),
375                )),
376                Box_::into_raw(f),
377            )
378        }
379    }
380
381    #[doc(alias = "certificate")]
382    fn connect_certificate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
383        unsafe extern "C" fn notify_certificate_trampoline<
384            P: IsA<TlsConnection>,
385            F: Fn(&P) + 'static,
386        >(
387            this: *mut ffi::GTlsConnection,
388            _param_spec: glib::ffi::gpointer,
389            f: glib::ffi::gpointer,
390        ) {
391            let f: &F = &*(f as *const F);
392            f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref())
393        }
394        unsafe {
395            let f: Box_<F> = Box_::new(f);
396            connect_raw(
397                self.as_ptr() as *mut _,
398                c"notify::certificate".as_ptr() as *const _,
399                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
400                    notify_certificate_trampoline::<Self, F> as *const (),
401                )),
402                Box_::into_raw(f),
403            )
404        }
405    }
406
407    #[cfg(feature = "v2_70")]
408    #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
409    #[doc(alias = "ciphersuite-name")]
410    fn connect_ciphersuite_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
411        unsafe extern "C" fn notify_ciphersuite_name_trampoline<
412            P: IsA<TlsConnection>,
413            F: Fn(&P) + 'static,
414        >(
415            this: *mut ffi::GTlsConnection,
416            _param_spec: glib::ffi::gpointer,
417            f: glib::ffi::gpointer,
418        ) {
419            let f: &F = &*(f as *const F);
420            f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref())
421        }
422        unsafe {
423            let f: Box_<F> = Box_::new(f);
424            connect_raw(
425                self.as_ptr() as *mut _,
426                c"notify::ciphersuite-name".as_ptr() as *const _,
427                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
428                    notify_ciphersuite_name_trampoline::<Self, F> as *const (),
429                )),
430                Box_::into_raw(f),
431            )
432        }
433    }
434
435    #[doc(alias = "database")]
436    fn connect_database_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
437        unsafe extern "C" fn notify_database_trampoline<
438            P: IsA<TlsConnection>,
439            F: Fn(&P) + 'static,
440        >(
441            this: *mut ffi::GTlsConnection,
442            _param_spec: glib::ffi::gpointer,
443            f: glib::ffi::gpointer,
444        ) {
445            let f: &F = &*(f as *const F);
446            f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref())
447        }
448        unsafe {
449            let f: Box_<F> = Box_::new(f);
450            connect_raw(
451                self.as_ptr() as *mut _,
452                c"notify::database".as_ptr() as *const _,
453                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
454                    notify_database_trampoline::<Self, F> as *const (),
455                )),
456                Box_::into_raw(f),
457            )
458        }
459    }
460
461    #[doc(alias = "interaction")]
462    fn connect_interaction_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
463        unsafe extern "C" fn notify_interaction_trampoline<
464            P: IsA<TlsConnection>,
465            F: Fn(&P) + 'static,
466        >(
467            this: *mut ffi::GTlsConnection,
468            _param_spec: glib::ffi::gpointer,
469            f: glib::ffi::gpointer,
470        ) {
471            let f: &F = &*(f as *const F);
472            f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref())
473        }
474        unsafe {
475            let f: Box_<F> = Box_::new(f);
476            connect_raw(
477                self.as_ptr() as *mut _,
478                c"notify::interaction".as_ptr() as *const _,
479                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
480                    notify_interaction_trampoline::<Self, F> as *const (),
481                )),
482                Box_::into_raw(f),
483            )
484        }
485    }
486
487    #[cfg(feature = "v2_60")]
488    #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
489    #[doc(alias = "negotiated-protocol")]
490    fn connect_negotiated_protocol_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
491        unsafe extern "C" fn notify_negotiated_protocol_trampoline<
492            P: IsA<TlsConnection>,
493            F: Fn(&P) + 'static,
494        >(
495            this: *mut ffi::GTlsConnection,
496            _param_spec: glib::ffi::gpointer,
497            f: glib::ffi::gpointer,
498        ) {
499            let f: &F = &*(f as *const F);
500            f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref())
501        }
502        unsafe {
503            let f: Box_<F> = Box_::new(f);
504            connect_raw(
505                self.as_ptr() as *mut _,
506                c"notify::negotiated-protocol".as_ptr() as *const _,
507                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
508                    notify_negotiated_protocol_trampoline::<Self, F> as *const (),
509                )),
510                Box_::into_raw(f),
511            )
512        }
513    }
514
515    #[doc(alias = "peer-certificate")]
516    fn connect_peer_certificate_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
517        unsafe extern "C" fn notify_peer_certificate_trampoline<
518            P: IsA<TlsConnection>,
519            F: Fn(&P) + 'static,
520        >(
521            this: *mut ffi::GTlsConnection,
522            _param_spec: glib::ffi::gpointer,
523            f: glib::ffi::gpointer,
524        ) {
525            let f: &F = &*(f as *const F);
526            f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref())
527        }
528        unsafe {
529            let f: Box_<F> = Box_::new(f);
530            connect_raw(
531                self.as_ptr() as *mut _,
532                c"notify::peer-certificate".as_ptr() as *const _,
533                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
534                    notify_peer_certificate_trampoline::<Self, F> as *const (),
535                )),
536                Box_::into_raw(f),
537            )
538        }
539    }
540
541    #[doc(alias = "peer-certificate-errors")]
542    fn connect_peer_certificate_errors_notify<F: Fn(&Self) + 'static>(
543        &self,
544        f: F,
545    ) -> SignalHandlerId {
546        unsafe extern "C" fn notify_peer_certificate_errors_trampoline<
547            P: IsA<TlsConnection>,
548            F: Fn(&P) + 'static,
549        >(
550            this: *mut ffi::GTlsConnection,
551            _param_spec: glib::ffi::gpointer,
552            f: glib::ffi::gpointer,
553        ) {
554            let f: &F = &*(f as *const F);
555            f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref())
556        }
557        unsafe {
558            let f: Box_<F> = Box_::new(f);
559            connect_raw(
560                self.as_ptr() as *mut _,
561                c"notify::peer-certificate-errors".as_ptr() as *const _,
562                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
563                    notify_peer_certificate_errors_trampoline::<Self, F> as *const (),
564                )),
565                Box_::into_raw(f),
566            )
567        }
568    }
569
570    #[cfg(feature = "v2_70")]
571    #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
572    #[doc(alias = "protocol-version")]
573    fn connect_protocol_version_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
574        unsafe extern "C" fn notify_protocol_version_trampoline<
575            P: IsA<TlsConnection>,
576            F: Fn(&P) + 'static,
577        >(
578            this: *mut ffi::GTlsConnection,
579            _param_spec: glib::ffi::gpointer,
580            f: glib::ffi::gpointer,
581        ) {
582            let f: &F = &*(f as *const F);
583            f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref())
584        }
585        unsafe {
586            let f: Box_<F> = Box_::new(f);
587            connect_raw(
588                self.as_ptr() as *mut _,
589                c"notify::protocol-version".as_ptr() as *const _,
590                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
591                    notify_protocol_version_trampoline::<Self, F> as *const (),
592                )),
593                Box_::into_raw(f),
594            )
595        }
596    }
597
598    #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")]
599    #[doc(alias = "rehandshake-mode")]
600    fn connect_rehandshake_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
601        unsafe extern "C" fn notify_rehandshake_mode_trampoline<
602            P: IsA<TlsConnection>,
603            F: Fn(&P) + 'static,
604        >(
605            this: *mut ffi::GTlsConnection,
606            _param_spec: glib::ffi::gpointer,
607            f: glib::ffi::gpointer,
608        ) {
609            let f: &F = &*(f as *const F);
610            f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref())
611        }
612        unsafe {
613            let f: Box_<F> = Box_::new(f);
614            connect_raw(
615                self.as_ptr() as *mut _,
616                c"notify::rehandshake-mode".as_ptr() as *const _,
617                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
618                    notify_rehandshake_mode_trampoline::<Self, F> as *const (),
619                )),
620                Box_::into_raw(f),
621            )
622        }
623    }
624
625    #[doc(alias = "require-close-notify")]
626    fn connect_require_close_notify_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
627        unsafe extern "C" fn notify_require_close_notify_trampoline<
628            P: IsA<TlsConnection>,
629            F: Fn(&P) + 'static,
630        >(
631            this: *mut ffi::GTlsConnection,
632            _param_spec: glib::ffi::gpointer,
633            f: glib::ffi::gpointer,
634        ) {
635            let f: &F = &*(f as *const F);
636            f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref())
637        }
638        unsafe {
639            let f: Box_<F> = Box_::new(f);
640            connect_raw(
641                self.as_ptr() as *mut _,
642                c"notify::require-close-notify".as_ptr() as *const _,
643                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
644                    notify_require_close_notify_trampoline::<Self, F> as *const (),
645                )),
646                Box_::into_raw(f),
647            )
648        }
649    }
650}
651
652impl<O: IsA<TlsConnection>> TlsConnectionExt for O {}