1 // Take a look at the license at the top of the repository in the LICENSE file. 2 3 #[cfg(any(feature = "v2_66", feature = "dox"))] 4 use crate::TlsChannelBindingType; 5 use crate::TlsConnection; 6 #[cfg(any(feature = "v2_66", feature = "dox"))] 7 use glib::translate::*; 8 use glib::IsA; 9 #[cfg(any(feature = "v2_66", feature = "dox"))] 10 use std::ptr; 11 12 pub trait TlsConnectionExtManual { 13 #[cfg(any(feature = "v2_66", feature = "dox"))] 14 #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] 15 #[doc(alias = "g_tls_connection_get_channel_binding_data")] 16 #[doc(alias = "get_channel_binding_data")] channel_binding_data( &self, type_: TlsChannelBindingType, ) -> Result<glib::ByteArray, glib::Error>17 fn channel_binding_data( 18 &self, 19 type_: TlsChannelBindingType, 20 ) -> Result<glib::ByteArray, glib::Error>; 21 } 22 23 impl<O: IsA<TlsConnection>> TlsConnectionExtManual for O { 24 #[cfg(any(feature = "v2_66", feature = "dox"))] 25 #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] channel_binding_data( &self, type_: TlsChannelBindingType, ) -> Result<glib::ByteArray, glib::Error>26 fn channel_binding_data( 27 &self, 28 type_: TlsChannelBindingType, 29 ) -> Result<glib::ByteArray, glib::Error> { 30 unsafe { 31 let data = ptr::null_mut(); 32 let mut error = ptr::null_mut(); 33 let _ = ffi::g_tls_connection_get_channel_binding_data( 34 self.as_ptr() as *mut _, 35 type_.into_glib(), 36 data, 37 &mut error, 38 ); 39 if error.is_null() { 40 Ok(from_glib_none(data)) 41 } else { 42 Err(from_glib_full(error)) 43 } 44 } 45 } 46 } 47