gio/
tls_connection.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3#[cfg(feature = "v2_66")]
4use std::ptr;
5
6use glib::prelude::*;
7#[cfg(feature = "v2_60")]
8use glib::translate::*;
9
10#[cfg(feature = "v2_66")]
11use crate::TlsChannelBindingType;
12use crate::TlsConnection;
13
14mod sealed {
15    pub trait Sealed {}
16    impl<T: super::IsA<super::TlsConnection>> Sealed for T {}
17}
18
19pub trait TlsConnectionExtManual: sealed::Sealed + IsA<TlsConnection> {
20    #[cfg(feature = "v2_66")]
21    #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
22    #[doc(alias = "g_tls_connection_get_channel_binding_data")]
23    #[doc(alias = "get_channel_binding_data")]
24    fn channel_binding_data(
25        &self,
26        type_: TlsChannelBindingType,
27    ) -> Result<glib::ByteArray, glib::Error> {
28        unsafe {
29            let data = ptr::null_mut();
30            let mut error = ptr::null_mut();
31            let _ = crate::ffi::g_tls_connection_get_channel_binding_data(
32                self.as_ptr() as *mut _,
33                type_.into_glib(),
34                data,
35                &mut error,
36            );
37            if error.is_null() {
38                Ok(from_glib_none(data))
39            } else {
40                Err(from_glib_full(error))
41            }
42        }
43    }
44
45    #[cfg(feature = "v2_60")]
46    #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
47    #[doc(alias = "g_tls_connection_set_advertised_protocols")]
48    fn set_advertised_protocols(&self, protocols: impl IntoStrV) {
49        unsafe {
50            protocols.run_with_strv(|protocols| {
51                crate::ffi::g_tls_connection_set_advertised_protocols(
52                    self.as_ref().to_glib_none().0,
53                    protocols.as_ptr() as *mut _,
54                );
55            })
56        }
57    }
58}
59
60impl<O: IsA<TlsConnection>> TlsConnectionExtManual for O {}