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
14pub trait TlsConnectionExtManual: IsA<TlsConnection> {
15    #[cfg(feature = "v2_66")]
16    #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
17    #[doc(alias = "g_tls_connection_get_channel_binding_data")]
18    #[doc(alias = "get_channel_binding_data")]
19    fn channel_binding_data(
20        &self,
21        type_: TlsChannelBindingType,
22    ) -> Result<glib::ByteArray, glib::Error> {
23        unsafe {
24            let data = ptr::null_mut();
25            let mut error = ptr::null_mut();
26            let _ = crate::ffi::g_tls_connection_get_channel_binding_data(
27                self.as_ptr() as *mut _,
28                type_.into_glib(),
29                data,
30                &mut error,
31            );
32            if error.is_null() {
33                Ok(from_glib_none(data))
34            } else {
35                Err(from_glib_full(error))
36            }
37        }
38    }
39
40    #[cfg(feature = "v2_60")]
41    #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
42    #[doc(alias = "g_tls_connection_set_advertised_protocols")]
43    fn set_advertised_protocols(&self, protocols: impl IntoStrV) {
44        unsafe {
45            protocols.run_with_strv(|protocols| {
46                crate::ffi::g_tls_connection_set_advertised_protocols(
47                    self.as_ref().to_glib_none().0,
48                    protocols.as_ptr() as *mut _,
49                );
50            })
51        }
52    }
53}
54
55impl<O: IsA<TlsConnection>> TlsConnectionExtManual for O {}