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 5 use crate::IOStream; 6 use crate::TlsAuthenticationMode; 7 use crate::TlsCertificate; 8 use crate::TlsConnection; 9 use glib::object::Cast; 10 use glib::object::IsA; 11 use glib::signal::connect_raw; 12 use glib::signal::SignalHandlerId; 13 use glib::translate::*; 14 use glib::StaticType; 15 use glib::ToValue; 16 use std::boxed::Box as Box_; 17 use std::fmt; 18 use std::mem::transmute; 19 use std::ptr; 20 21 glib::wrapper! { 22 #[doc(alias = "GTlsServerConnection")] 23 pub struct TlsServerConnection(Interface<ffi::GTlsServerConnection, ffi::GTlsServerConnectionInterface>) @requires TlsConnection, IOStream; 24 25 match fn { 26 type_ => || ffi::g_tls_server_connection_get_type(), 27 } 28 } 29 30 impl TlsServerConnection { 31 #[doc(alias = "g_tls_server_connection_new")] new<P: IsA<IOStream>, Q: IsA<TlsCertificate>>( base_io_stream: &P, certificate: Option<&Q>, ) -> Result<TlsServerConnection, glib::Error>32 pub fn new<P: IsA<IOStream>, Q: IsA<TlsCertificate>>( 33 base_io_stream: &P, 34 certificate: Option<&Q>, 35 ) -> Result<TlsServerConnection, glib::Error> { 36 unsafe { 37 let mut error = ptr::null_mut(); 38 let ret = ffi::g_tls_server_connection_new( 39 base_io_stream.as_ref().to_glib_none().0, 40 certificate.map(|p| p.as_ref()).to_glib_none().0, 41 &mut error, 42 ); 43 if error.is_null() { 44 Ok(from_glib_full(ret)) 45 } else { 46 Err(from_glib_full(error)) 47 } 48 } 49 } 50 } 51 52 pub const NONE_TLS_SERVER_CONNECTION: Option<&TlsServerConnection> = None; 53 54 pub trait TlsServerConnectionExt: 'static { 55 #[doc(alias = "authentication-mode")] authentication_mode(&self) -> TlsAuthenticationMode56 fn authentication_mode(&self) -> TlsAuthenticationMode; 57 58 #[doc(alias = "authentication-mode")] set_authentication_mode(&self, authentication_mode: TlsAuthenticationMode)59 fn set_authentication_mode(&self, authentication_mode: TlsAuthenticationMode); 60 61 #[doc(alias = "authentication-mode")] connect_authentication_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId62 fn connect_authentication_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 63 } 64 65 impl<O: IsA<TlsServerConnection>> TlsServerConnectionExt for O { authentication_mode(&self) -> TlsAuthenticationMode66 fn authentication_mode(&self) -> TlsAuthenticationMode { 67 unsafe { 68 let mut value = 69 glib::Value::from_type(<TlsAuthenticationMode as StaticType>::static_type()); 70 glib::gobject_ffi::g_object_get_property( 71 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 72 b"authentication-mode\0".as_ptr() as *const _, 73 value.to_glib_none_mut().0, 74 ); 75 value 76 .get() 77 .expect("Return Value for property `authentication-mode` getter") 78 } 79 } 80 set_authentication_mode(&self, authentication_mode: TlsAuthenticationMode)81 fn set_authentication_mode(&self, authentication_mode: TlsAuthenticationMode) { 82 unsafe { 83 glib::gobject_ffi::g_object_set_property( 84 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 85 b"authentication-mode\0".as_ptr() as *const _, 86 authentication_mode.to_value().to_glib_none().0, 87 ); 88 } 89 } 90 connect_authentication_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId91 fn connect_authentication_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 92 unsafe extern "C" fn notify_authentication_mode_trampoline< 93 P: IsA<TlsServerConnection>, 94 F: Fn(&P) + 'static, 95 >( 96 this: *mut ffi::GTlsServerConnection, 97 _param_spec: glib::ffi::gpointer, 98 f: glib::ffi::gpointer, 99 ) { 100 let f: &F = &*(f as *const F); 101 f(TlsServerConnection::from_glib_borrow(this).unsafe_cast_ref()) 102 } 103 unsafe { 104 let f: Box_<F> = Box_::new(f); 105 connect_raw( 106 self.as_ptr() as *mut _, 107 b"notify::authentication-mode\0".as_ptr() as *const _, 108 Some(transmute::<_, unsafe extern "C" fn()>( 109 notify_authentication_mode_trampoline::<Self, F> as *const (), 110 )), 111 Box_::into_raw(f), 112 ) 113 } 114 } 115 } 116 117 impl fmt::Display for TlsServerConnection { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result118 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 119 f.write_str("TlsServerConnection") 120 } 121 } 122