gio/auto/
socket_client.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
5#[cfg(feature = "futures")]
6use futures::future;
7use gio_sys;
8use glib::object::Cast;
9use glib::object::IsA;
10use glib::signal::connect_raw;
11use glib::signal::SignalHandlerId;
12use glib::translate::*;
13use glib::StaticType;
14use glib::Value;
15use glib_sys;
16use gobject_sys;
17use std::boxed::Box as Box_;
18use std::fmt;
19use std::mem::transmute;
20use std::ptr;
21use Cancellable;
22use Error;
23use IOStream;
24use ProxyResolver;
25use SocketAddress;
26use SocketClientEvent;
27use SocketConnectable;
28use SocketConnection;
29use SocketFamily;
30use SocketProtocol;
31use SocketType;
32use TlsCertificateFlags;
33
34glib_wrapper! {
35    pub struct SocketClient(Object<gio_sys::GSocketClient, gio_sys::GSocketClientClass, SocketClientClass>);
36
37    match fn {
38        get_type => || gio_sys::g_socket_client_get_type(),
39    }
40}
41
42impl SocketClient {
43    pub fn new() -> SocketClient {
44        unsafe { from_glib_full(gio_sys::g_socket_client_new()) }
45    }
46}
47
48impl Default for SocketClient {
49    fn default() -> Self {
50        Self::new()
51    }
52}
53
54pub const NONE_SOCKET_CLIENT: Option<&SocketClient> = None;
55
56pub trait SocketClientExt: 'static {
57    fn add_application_proxy(&self, protocol: &str);
58
59    fn connect<P: IsA<SocketConnectable>, Q: IsA<Cancellable>>(
60        &self,
61        connectable: &P,
62        cancellable: Option<&Q>,
63    ) -> Result<SocketConnection, Error>;
64
65    fn connect_async<
66        P: IsA<SocketConnectable>,
67        Q: IsA<Cancellable>,
68        R: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
69    >(
70        &self,
71        connectable: &P,
72        cancellable: Option<&Q>,
73        callback: R,
74    );
75
76    #[cfg(feature = "futures")]
77    fn connect_async_future<P: IsA<SocketConnectable> + Clone + 'static>(
78        &self,
79        connectable: &P,
80    ) -> Box_<dyn future::Future<Output = Result<SocketConnection, Error>> + std::marker::Unpin>;
81
82    fn connect_to_host<P: IsA<Cancellable>>(
83        &self,
84        host_and_port: &str,
85        default_port: u16,
86        cancellable: Option<&P>,
87    ) -> Result<SocketConnection, Error>;
88
89    fn connect_to_host_async<
90        P: IsA<Cancellable>,
91        Q: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
92    >(
93        &self,
94        host_and_port: &str,
95        default_port: u16,
96        cancellable: Option<&P>,
97        callback: Q,
98    );
99
100    #[cfg(feature = "futures")]
101    fn connect_to_host_async_future(
102        &self,
103        host_and_port: &str,
104        default_port: u16,
105    ) -> Box_<dyn future::Future<Output = Result<SocketConnection, Error>> + std::marker::Unpin>;
106
107    fn connect_to_service<P: IsA<Cancellable>>(
108        &self,
109        domain: &str,
110        service: &str,
111        cancellable: Option<&P>,
112    ) -> Result<SocketConnection, Error>;
113
114    fn connect_to_service_async<
115        P: IsA<Cancellable>,
116        Q: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
117    >(
118        &self,
119        domain: &str,
120        service: &str,
121        cancellable: Option<&P>,
122        callback: Q,
123    );
124
125    #[cfg(feature = "futures")]
126    fn connect_to_service_async_future(
127        &self,
128        domain: &str,
129        service: &str,
130    ) -> Box_<dyn future::Future<Output = Result<SocketConnection, Error>> + std::marker::Unpin>;
131
132    fn connect_to_uri<P: IsA<Cancellable>>(
133        &self,
134        uri: &str,
135        default_port: u16,
136        cancellable: Option<&P>,
137    ) -> Result<SocketConnection, Error>;
138
139    fn connect_to_uri_async<
140        P: IsA<Cancellable>,
141        Q: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
142    >(
143        &self,
144        uri: &str,
145        default_port: u16,
146        cancellable: Option<&P>,
147        callback: Q,
148    );
149
150    #[cfg(feature = "futures")]
151    fn connect_to_uri_async_future(
152        &self,
153        uri: &str,
154        default_port: u16,
155    ) -> Box_<dyn future::Future<Output = Result<SocketConnection, Error>> + std::marker::Unpin>;
156
157    fn get_enable_proxy(&self) -> bool;
158
159    fn get_family(&self) -> SocketFamily;
160
161    fn get_local_address(&self) -> Option<SocketAddress>;
162
163    fn get_protocol(&self) -> SocketProtocol;
164
165    fn get_proxy_resolver(&self) -> Option<ProxyResolver>;
166
167    fn get_socket_type(&self) -> SocketType;
168
169    fn get_timeout(&self) -> u32;
170
171    fn get_tls(&self) -> bool;
172
173    fn get_tls_validation_flags(&self) -> TlsCertificateFlags;
174
175    fn set_enable_proxy(&self, enable: bool);
176
177    fn set_family(&self, family: SocketFamily);
178
179    fn set_local_address<P: IsA<SocketAddress>>(&self, address: Option<&P>);
180
181    fn set_protocol(&self, protocol: SocketProtocol);
182
183    fn set_proxy_resolver<P: IsA<ProxyResolver>>(&self, proxy_resolver: Option<&P>);
184
185    fn set_socket_type(&self, type_: SocketType);
186
187    fn set_timeout(&self, timeout: u32);
188
189    fn set_tls(&self, tls: bool);
190
191    fn set_tls_validation_flags(&self, flags: TlsCertificateFlags);
192
193    fn get_property_type(&self) -> SocketType;
194
195    fn set_property_type(&self, type_: SocketType);
196
197    fn connect_event<
198        F: Fn(&Self, SocketClientEvent, &SocketConnectable, Option<&IOStream>) + 'static,
199    >(
200        &self,
201        f: F,
202    ) -> SignalHandlerId;
203
204    fn connect_property_enable_proxy_notify<F: Fn(&Self) + 'static>(&self, f: F)
205        -> SignalHandlerId;
206
207    fn connect_property_family_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
208
209    fn connect_property_local_address_notify<F: Fn(&Self) + 'static>(
210        &self,
211        f: F,
212    ) -> SignalHandlerId;
213
214    fn connect_property_protocol_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
215
216    fn connect_property_proxy_resolver_notify<F: Fn(&Self) + 'static>(
217        &self,
218        f: F,
219    ) -> SignalHandlerId;
220
221    fn connect_property_timeout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
222
223    fn connect_property_tls_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
224
225    fn connect_property_tls_validation_flags_notify<F: Fn(&Self) + 'static>(
226        &self,
227        f: F,
228    ) -> SignalHandlerId;
229
230    fn connect_property_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
231}
232
233impl<O: IsA<SocketClient>> SocketClientExt for O {
234    fn add_application_proxy(&self, protocol: &str) {
235        unsafe {
236            gio_sys::g_socket_client_add_application_proxy(
237                self.as_ref().to_glib_none().0,
238                protocol.to_glib_none().0,
239            );
240        }
241    }
242
243    fn connect<P: IsA<SocketConnectable>, Q: IsA<Cancellable>>(
244        &self,
245        connectable: &P,
246        cancellable: Option<&Q>,
247    ) -> Result<SocketConnection, Error> {
248        unsafe {
249            let mut error = ptr::null_mut();
250            let ret = gio_sys::g_socket_client_connect(
251                self.as_ref().to_glib_none().0,
252                connectable.as_ref().to_glib_none().0,
253                cancellable.map(|p| p.as_ref()).to_glib_none().0,
254                &mut error,
255            );
256            if error.is_null() {
257                Ok(from_glib_full(ret))
258            } else {
259                Err(from_glib_full(error))
260            }
261        }
262    }
263
264    fn connect_async<
265        P: IsA<SocketConnectable>,
266        Q: IsA<Cancellable>,
267        R: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
268    >(
269        &self,
270        connectable: &P,
271        cancellable: Option<&Q>,
272        callback: R,
273    ) {
274        let user_data: Box<R> = Box::new(callback);
275        unsafe extern "C" fn connect_async_trampoline<
276            R: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
277        >(
278            _source_object: *mut gobject_sys::GObject,
279            res: *mut gio_sys::GAsyncResult,
280            user_data: glib_sys::gpointer,
281        ) {
282            let mut error = ptr::null_mut();
283            let ret =
284                gio_sys::g_socket_client_connect_finish(_source_object as *mut _, res, &mut error);
285            let result = if error.is_null() {
286                Ok(from_glib_full(ret))
287            } else {
288                Err(from_glib_full(error))
289            };
290            let callback: Box<R> = Box::from_raw(user_data as *mut _);
291            callback(result);
292        }
293        let callback = connect_async_trampoline::<R>;
294        unsafe {
295            gio_sys::g_socket_client_connect_async(
296                self.as_ref().to_glib_none().0,
297                connectable.as_ref().to_glib_none().0,
298                cancellable.map(|p| p.as_ref()).to_glib_none().0,
299                Some(callback),
300                Box::into_raw(user_data) as *mut _,
301            );
302        }
303    }
304
305    #[cfg(feature = "futures")]
306    fn connect_async_future<P: IsA<SocketConnectable> + Clone + 'static>(
307        &self,
308        connectable: &P,
309    ) -> Box_<dyn future::Future<Output = Result<SocketConnection, Error>> + std::marker::Unpin>
310    {
311        use fragile::Fragile;
312        use GioFuture;
313
314        let connectable = connectable.clone();
315        GioFuture::new(self, move |obj, send| {
316            let cancellable = Cancellable::new();
317            let send = Fragile::new(send);
318            obj.connect_async(&connectable, Some(&cancellable), move |res| {
319                let _ = send.into_inner().send(res);
320            });
321
322            cancellable
323        })
324    }
325
326    fn connect_to_host<P: IsA<Cancellable>>(
327        &self,
328        host_and_port: &str,
329        default_port: u16,
330        cancellable: Option<&P>,
331    ) -> Result<SocketConnection, Error> {
332        unsafe {
333            let mut error = ptr::null_mut();
334            let ret = gio_sys::g_socket_client_connect_to_host(
335                self.as_ref().to_glib_none().0,
336                host_and_port.to_glib_none().0,
337                default_port,
338                cancellable.map(|p| p.as_ref()).to_glib_none().0,
339                &mut error,
340            );
341            if error.is_null() {
342                Ok(from_glib_full(ret))
343            } else {
344                Err(from_glib_full(error))
345            }
346        }
347    }
348
349    fn connect_to_host_async<
350        P: IsA<Cancellable>,
351        Q: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
352    >(
353        &self,
354        host_and_port: &str,
355        default_port: u16,
356        cancellable: Option<&P>,
357        callback: Q,
358    ) {
359        let user_data: Box<Q> = Box::new(callback);
360        unsafe extern "C" fn connect_to_host_async_trampoline<
361            Q: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
362        >(
363            _source_object: *mut gobject_sys::GObject,
364            res: *mut gio_sys::GAsyncResult,
365            user_data: glib_sys::gpointer,
366        ) {
367            let mut error = ptr::null_mut();
368            let ret = gio_sys::g_socket_client_connect_to_host_finish(
369                _source_object as *mut _,
370                res,
371                &mut error,
372            );
373            let result = if error.is_null() {
374                Ok(from_glib_full(ret))
375            } else {
376                Err(from_glib_full(error))
377            };
378            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
379            callback(result);
380        }
381        let callback = connect_to_host_async_trampoline::<Q>;
382        unsafe {
383            gio_sys::g_socket_client_connect_to_host_async(
384                self.as_ref().to_glib_none().0,
385                host_and_port.to_glib_none().0,
386                default_port,
387                cancellable.map(|p| p.as_ref()).to_glib_none().0,
388                Some(callback),
389                Box::into_raw(user_data) as *mut _,
390            );
391        }
392    }
393
394    #[cfg(feature = "futures")]
395    fn connect_to_host_async_future(
396        &self,
397        host_and_port: &str,
398        default_port: u16,
399    ) -> Box_<dyn future::Future<Output = Result<SocketConnection, Error>> + std::marker::Unpin>
400    {
401        use fragile::Fragile;
402        use GioFuture;
403
404        let host_and_port = String::from(host_and_port);
405        GioFuture::new(self, move |obj, send| {
406            let cancellable = Cancellable::new();
407            let send = Fragile::new(send);
408            obj.connect_to_host_async(
409                &host_and_port,
410                default_port,
411                Some(&cancellable),
412                move |res| {
413                    let _ = send.into_inner().send(res);
414                },
415            );
416
417            cancellable
418        })
419    }
420
421    fn connect_to_service<P: IsA<Cancellable>>(
422        &self,
423        domain: &str,
424        service: &str,
425        cancellable: Option<&P>,
426    ) -> Result<SocketConnection, Error> {
427        unsafe {
428            let mut error = ptr::null_mut();
429            let ret = gio_sys::g_socket_client_connect_to_service(
430                self.as_ref().to_glib_none().0,
431                domain.to_glib_none().0,
432                service.to_glib_none().0,
433                cancellable.map(|p| p.as_ref()).to_glib_none().0,
434                &mut error,
435            );
436            if error.is_null() {
437                Ok(from_glib_full(ret))
438            } else {
439                Err(from_glib_full(error))
440            }
441        }
442    }
443
444    fn connect_to_service_async<
445        P: IsA<Cancellable>,
446        Q: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
447    >(
448        &self,
449        domain: &str,
450        service: &str,
451        cancellable: Option<&P>,
452        callback: Q,
453    ) {
454        let user_data: Box<Q> = Box::new(callback);
455        unsafe extern "C" fn connect_to_service_async_trampoline<
456            Q: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
457        >(
458            _source_object: *mut gobject_sys::GObject,
459            res: *mut gio_sys::GAsyncResult,
460            user_data: glib_sys::gpointer,
461        ) {
462            let mut error = ptr::null_mut();
463            let ret = gio_sys::g_socket_client_connect_to_service_finish(
464                _source_object as *mut _,
465                res,
466                &mut error,
467            );
468            let result = if error.is_null() {
469                Ok(from_glib_full(ret))
470            } else {
471                Err(from_glib_full(error))
472            };
473            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
474            callback(result);
475        }
476        let callback = connect_to_service_async_trampoline::<Q>;
477        unsafe {
478            gio_sys::g_socket_client_connect_to_service_async(
479                self.as_ref().to_glib_none().0,
480                domain.to_glib_none().0,
481                service.to_glib_none().0,
482                cancellable.map(|p| p.as_ref()).to_glib_none().0,
483                Some(callback),
484                Box::into_raw(user_data) as *mut _,
485            );
486        }
487    }
488
489    #[cfg(feature = "futures")]
490    fn connect_to_service_async_future(
491        &self,
492        domain: &str,
493        service: &str,
494    ) -> Box_<dyn future::Future<Output = Result<SocketConnection, Error>> + std::marker::Unpin>
495    {
496        use fragile::Fragile;
497        use GioFuture;
498
499        let domain = String::from(domain);
500        let service = String::from(service);
501        GioFuture::new(self, move |obj, send| {
502            let cancellable = Cancellable::new();
503            let send = Fragile::new(send);
504            obj.connect_to_service_async(&domain, &service, Some(&cancellable), move |res| {
505                let _ = send.into_inner().send(res);
506            });
507
508            cancellable
509        })
510    }
511
512    fn connect_to_uri<P: IsA<Cancellable>>(
513        &self,
514        uri: &str,
515        default_port: u16,
516        cancellable: Option<&P>,
517    ) -> Result<SocketConnection, Error> {
518        unsafe {
519            let mut error = ptr::null_mut();
520            let ret = gio_sys::g_socket_client_connect_to_uri(
521                self.as_ref().to_glib_none().0,
522                uri.to_glib_none().0,
523                default_port,
524                cancellable.map(|p| p.as_ref()).to_glib_none().0,
525                &mut error,
526            );
527            if error.is_null() {
528                Ok(from_glib_full(ret))
529            } else {
530                Err(from_glib_full(error))
531            }
532        }
533    }
534
535    fn connect_to_uri_async<
536        P: IsA<Cancellable>,
537        Q: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
538    >(
539        &self,
540        uri: &str,
541        default_port: u16,
542        cancellable: Option<&P>,
543        callback: Q,
544    ) {
545        let user_data: Box<Q> = Box::new(callback);
546        unsafe extern "C" fn connect_to_uri_async_trampoline<
547            Q: FnOnce(Result<SocketConnection, Error>) + Send + 'static,
548        >(
549            _source_object: *mut gobject_sys::GObject,
550            res: *mut gio_sys::GAsyncResult,
551            user_data: glib_sys::gpointer,
552        ) {
553            let mut error = ptr::null_mut();
554            let ret = gio_sys::g_socket_client_connect_to_uri_finish(
555                _source_object as *mut _,
556                res,
557                &mut error,
558            );
559            let result = if error.is_null() {
560                Ok(from_glib_full(ret))
561            } else {
562                Err(from_glib_full(error))
563            };
564            let callback: Box<Q> = Box::from_raw(user_data as *mut _);
565            callback(result);
566        }
567        let callback = connect_to_uri_async_trampoline::<Q>;
568        unsafe {
569            gio_sys::g_socket_client_connect_to_uri_async(
570                self.as_ref().to_glib_none().0,
571                uri.to_glib_none().0,
572                default_port,
573                cancellable.map(|p| p.as_ref()).to_glib_none().0,
574                Some(callback),
575                Box::into_raw(user_data) as *mut _,
576            );
577        }
578    }
579
580    #[cfg(feature = "futures")]
581    fn connect_to_uri_async_future(
582        &self,
583        uri: &str,
584        default_port: u16,
585    ) -> Box_<dyn future::Future<Output = Result<SocketConnection, Error>> + std::marker::Unpin>
586    {
587        use fragile::Fragile;
588        use GioFuture;
589
590        let uri = String::from(uri);
591        GioFuture::new(self, move |obj, send| {
592            let cancellable = Cancellable::new();
593            let send = Fragile::new(send);
594            obj.connect_to_uri_async(&uri, default_port, Some(&cancellable), move |res| {
595                let _ = send.into_inner().send(res);
596            });
597
598            cancellable
599        })
600    }
601
602    fn get_enable_proxy(&self) -> bool {
603        unsafe {
604            from_glib(gio_sys::g_socket_client_get_enable_proxy(
605                self.as_ref().to_glib_none().0,
606            ))
607        }
608    }
609
610    fn get_family(&self) -> SocketFamily {
611        unsafe {
612            from_glib(gio_sys::g_socket_client_get_family(
613                self.as_ref().to_glib_none().0,
614            ))
615        }
616    }
617
618    fn get_local_address(&self) -> Option<SocketAddress> {
619        unsafe {
620            from_glib_none(gio_sys::g_socket_client_get_local_address(
621                self.as_ref().to_glib_none().0,
622            ))
623        }
624    }
625
626    fn get_protocol(&self) -> SocketProtocol {
627        unsafe {
628            from_glib(gio_sys::g_socket_client_get_protocol(
629                self.as_ref().to_glib_none().0,
630            ))
631        }
632    }
633
634    fn get_proxy_resolver(&self) -> Option<ProxyResolver> {
635        unsafe {
636            from_glib_none(gio_sys::g_socket_client_get_proxy_resolver(
637                self.as_ref().to_glib_none().0,
638            ))
639        }
640    }
641
642    fn get_socket_type(&self) -> SocketType {
643        unsafe {
644            from_glib(gio_sys::g_socket_client_get_socket_type(
645                self.as_ref().to_glib_none().0,
646            ))
647        }
648    }
649
650    fn get_timeout(&self) -> u32 {
651        unsafe { gio_sys::g_socket_client_get_timeout(self.as_ref().to_glib_none().0) }
652    }
653
654    fn get_tls(&self) -> bool {
655        unsafe {
656            from_glib(gio_sys::g_socket_client_get_tls(
657                self.as_ref().to_glib_none().0,
658            ))
659        }
660    }
661
662    fn get_tls_validation_flags(&self) -> TlsCertificateFlags {
663        unsafe {
664            from_glib(gio_sys::g_socket_client_get_tls_validation_flags(
665                self.as_ref().to_glib_none().0,
666            ))
667        }
668    }
669
670    fn set_enable_proxy(&self, enable: bool) {
671        unsafe {
672            gio_sys::g_socket_client_set_enable_proxy(
673                self.as_ref().to_glib_none().0,
674                enable.to_glib(),
675            );
676        }
677    }
678
679    fn set_family(&self, family: SocketFamily) {
680        unsafe {
681            gio_sys::g_socket_client_set_family(self.as_ref().to_glib_none().0, family.to_glib());
682        }
683    }
684
685    fn set_local_address<P: IsA<SocketAddress>>(&self, address: Option<&P>) {
686        unsafe {
687            gio_sys::g_socket_client_set_local_address(
688                self.as_ref().to_glib_none().0,
689                address.map(|p| p.as_ref()).to_glib_none().0,
690            );
691        }
692    }
693
694    fn set_protocol(&self, protocol: SocketProtocol) {
695        unsafe {
696            gio_sys::g_socket_client_set_protocol(
697                self.as_ref().to_glib_none().0,
698                protocol.to_glib(),
699            );
700        }
701    }
702
703    fn set_proxy_resolver<P: IsA<ProxyResolver>>(&self, proxy_resolver: Option<&P>) {
704        unsafe {
705            gio_sys::g_socket_client_set_proxy_resolver(
706                self.as_ref().to_glib_none().0,
707                proxy_resolver.map(|p| p.as_ref()).to_glib_none().0,
708            );
709        }
710    }
711
712    fn set_socket_type(&self, type_: SocketType) {
713        unsafe {
714            gio_sys::g_socket_client_set_socket_type(
715                self.as_ref().to_glib_none().0,
716                type_.to_glib(),
717            );
718        }
719    }
720
721    fn set_timeout(&self, timeout: u32) {
722        unsafe {
723            gio_sys::g_socket_client_set_timeout(self.as_ref().to_glib_none().0, timeout);
724        }
725    }
726
727    fn set_tls(&self, tls: bool) {
728        unsafe {
729            gio_sys::g_socket_client_set_tls(self.as_ref().to_glib_none().0, tls.to_glib());
730        }
731    }
732
733    fn set_tls_validation_flags(&self, flags: TlsCertificateFlags) {
734        unsafe {
735            gio_sys::g_socket_client_set_tls_validation_flags(
736                self.as_ref().to_glib_none().0,
737                flags.to_glib(),
738            );
739        }
740    }
741
742    fn get_property_type(&self) -> SocketType {
743        unsafe {
744            let mut value = Value::from_type(<SocketType as StaticType>::static_type());
745            gobject_sys::g_object_get_property(
746                self.to_glib_none().0 as *mut gobject_sys::GObject,
747                b"type\0".as_ptr() as *const _,
748                value.to_glib_none_mut().0,
749            );
750            value.get().unwrap()
751        }
752    }
753
754    fn set_property_type(&self, type_: SocketType) {
755        unsafe {
756            gobject_sys::g_object_set_property(
757                self.to_glib_none().0 as *mut gobject_sys::GObject,
758                b"type\0".as_ptr() as *const _,
759                Value::from(&type_).to_glib_none().0,
760            );
761        }
762    }
763
764    fn connect_event<
765        F: Fn(&Self, SocketClientEvent, &SocketConnectable, Option<&IOStream>) + 'static,
766    >(
767        &self,
768        f: F,
769    ) -> SignalHandlerId {
770        unsafe extern "C" fn event_trampoline<
771            P,
772            F: Fn(&P, SocketClientEvent, &SocketConnectable, Option<&IOStream>) + 'static,
773        >(
774            this: *mut gio_sys::GSocketClient,
775            event: gio_sys::GSocketClientEvent,
776            connectable: *mut gio_sys::GSocketConnectable,
777            connection: *mut gio_sys::GIOStream,
778            f: glib_sys::gpointer,
779        ) where
780            P: IsA<SocketClient>,
781        {
782            let f: &F = &*(f as *const F);
783            f(
784                &SocketClient::from_glib_borrow(this).unsafe_cast(),
785                from_glib(event),
786                &from_glib_borrow(connectable),
787                Option::<IOStream>::from_glib_borrow(connection).as_ref(),
788            )
789        }
790        unsafe {
791            let f: Box_<F> = Box_::new(f);
792            connect_raw(
793                self.as_ptr() as *mut _,
794                b"event\0".as_ptr() as *const _,
795                Some(transmute(event_trampoline::<Self, F> as usize)),
796                Box_::into_raw(f),
797            )
798        }
799    }
800
801    fn connect_property_enable_proxy_notify<F: Fn(&Self) + 'static>(
802        &self,
803        f: F,
804    ) -> SignalHandlerId {
805        unsafe extern "C" fn notify_enable_proxy_trampoline<P, F: Fn(&P) + 'static>(
806            this: *mut gio_sys::GSocketClient,
807            _param_spec: glib_sys::gpointer,
808            f: glib_sys::gpointer,
809        ) where
810            P: IsA<SocketClient>,
811        {
812            let f: &F = &*(f as *const F);
813            f(&SocketClient::from_glib_borrow(this).unsafe_cast())
814        }
815        unsafe {
816            let f: Box_<F> = Box_::new(f);
817            connect_raw(
818                self.as_ptr() as *mut _,
819                b"notify::enable-proxy\0".as_ptr() as *const _,
820                Some(transmute(
821                    notify_enable_proxy_trampoline::<Self, F> as usize,
822                )),
823                Box_::into_raw(f),
824            )
825        }
826    }
827
828    fn connect_property_family_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
829        unsafe extern "C" fn notify_family_trampoline<P, F: Fn(&P) + 'static>(
830            this: *mut gio_sys::GSocketClient,
831            _param_spec: glib_sys::gpointer,
832            f: glib_sys::gpointer,
833        ) where
834            P: IsA<SocketClient>,
835        {
836            let f: &F = &*(f as *const F);
837            f(&SocketClient::from_glib_borrow(this).unsafe_cast())
838        }
839        unsafe {
840            let f: Box_<F> = Box_::new(f);
841            connect_raw(
842                self.as_ptr() as *mut _,
843                b"notify::family\0".as_ptr() as *const _,
844                Some(transmute(notify_family_trampoline::<Self, F> as usize)),
845                Box_::into_raw(f),
846            )
847        }
848    }
849
850    fn connect_property_local_address_notify<F: Fn(&Self) + 'static>(
851        &self,
852        f: F,
853    ) -> SignalHandlerId {
854        unsafe extern "C" fn notify_local_address_trampoline<P, F: Fn(&P) + 'static>(
855            this: *mut gio_sys::GSocketClient,
856            _param_spec: glib_sys::gpointer,
857            f: glib_sys::gpointer,
858        ) where
859            P: IsA<SocketClient>,
860        {
861            let f: &F = &*(f as *const F);
862            f(&SocketClient::from_glib_borrow(this).unsafe_cast())
863        }
864        unsafe {
865            let f: Box_<F> = Box_::new(f);
866            connect_raw(
867                self.as_ptr() as *mut _,
868                b"notify::local-address\0".as_ptr() as *const _,
869                Some(transmute(
870                    notify_local_address_trampoline::<Self, F> as usize,
871                )),
872                Box_::into_raw(f),
873            )
874        }
875    }
876
877    fn connect_property_protocol_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
878        unsafe extern "C" fn notify_protocol_trampoline<P, F: Fn(&P) + 'static>(
879            this: *mut gio_sys::GSocketClient,
880            _param_spec: glib_sys::gpointer,
881            f: glib_sys::gpointer,
882        ) where
883            P: IsA<SocketClient>,
884        {
885            let f: &F = &*(f as *const F);
886            f(&SocketClient::from_glib_borrow(this).unsafe_cast())
887        }
888        unsafe {
889            let f: Box_<F> = Box_::new(f);
890            connect_raw(
891                self.as_ptr() as *mut _,
892                b"notify::protocol\0".as_ptr() as *const _,
893                Some(transmute(notify_protocol_trampoline::<Self, F> as usize)),
894                Box_::into_raw(f),
895            )
896        }
897    }
898
899    fn connect_property_proxy_resolver_notify<F: Fn(&Self) + 'static>(
900        &self,
901        f: F,
902    ) -> SignalHandlerId {
903        unsafe extern "C" fn notify_proxy_resolver_trampoline<P, F: Fn(&P) + 'static>(
904            this: *mut gio_sys::GSocketClient,
905            _param_spec: glib_sys::gpointer,
906            f: glib_sys::gpointer,
907        ) where
908            P: IsA<SocketClient>,
909        {
910            let f: &F = &*(f as *const F);
911            f(&SocketClient::from_glib_borrow(this).unsafe_cast())
912        }
913        unsafe {
914            let f: Box_<F> = Box_::new(f);
915            connect_raw(
916                self.as_ptr() as *mut _,
917                b"notify::proxy-resolver\0".as_ptr() as *const _,
918                Some(transmute(
919                    notify_proxy_resolver_trampoline::<Self, F> as usize,
920                )),
921                Box_::into_raw(f),
922            )
923        }
924    }
925
926    fn connect_property_timeout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
927        unsafe extern "C" fn notify_timeout_trampoline<P, F: Fn(&P) + 'static>(
928            this: *mut gio_sys::GSocketClient,
929            _param_spec: glib_sys::gpointer,
930            f: glib_sys::gpointer,
931        ) where
932            P: IsA<SocketClient>,
933        {
934            let f: &F = &*(f as *const F);
935            f(&SocketClient::from_glib_borrow(this).unsafe_cast())
936        }
937        unsafe {
938            let f: Box_<F> = Box_::new(f);
939            connect_raw(
940                self.as_ptr() as *mut _,
941                b"notify::timeout\0".as_ptr() as *const _,
942                Some(transmute(notify_timeout_trampoline::<Self, F> as usize)),
943                Box_::into_raw(f),
944            )
945        }
946    }
947
948    fn connect_property_tls_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
949        unsafe extern "C" fn notify_tls_trampoline<P, F: Fn(&P) + 'static>(
950            this: *mut gio_sys::GSocketClient,
951            _param_spec: glib_sys::gpointer,
952            f: glib_sys::gpointer,
953        ) where
954            P: IsA<SocketClient>,
955        {
956            let f: &F = &*(f as *const F);
957            f(&SocketClient::from_glib_borrow(this).unsafe_cast())
958        }
959        unsafe {
960            let f: Box_<F> = Box_::new(f);
961            connect_raw(
962                self.as_ptr() as *mut _,
963                b"notify::tls\0".as_ptr() as *const _,
964                Some(transmute(notify_tls_trampoline::<Self, F> as usize)),
965                Box_::into_raw(f),
966            )
967        }
968    }
969
970    fn connect_property_tls_validation_flags_notify<F: Fn(&Self) + 'static>(
971        &self,
972        f: F,
973    ) -> SignalHandlerId {
974        unsafe extern "C" fn notify_tls_validation_flags_trampoline<P, F: Fn(&P) + 'static>(
975            this: *mut gio_sys::GSocketClient,
976            _param_spec: glib_sys::gpointer,
977            f: glib_sys::gpointer,
978        ) where
979            P: IsA<SocketClient>,
980        {
981            let f: &F = &*(f as *const F);
982            f(&SocketClient::from_glib_borrow(this).unsafe_cast())
983        }
984        unsafe {
985            let f: Box_<F> = Box_::new(f);
986            connect_raw(
987                self.as_ptr() as *mut _,
988                b"notify::tls-validation-flags\0".as_ptr() as *const _,
989                Some(transmute(
990                    notify_tls_validation_flags_trampoline::<Self, F> as usize,
991                )),
992                Box_::into_raw(f),
993            )
994        }
995    }
996
997    fn connect_property_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
998        unsafe extern "C" fn notify_type_trampoline<P, F: Fn(&P) + 'static>(
999            this: *mut gio_sys::GSocketClient,
1000            _param_spec: glib_sys::gpointer,
1001            f: glib_sys::gpointer,
1002        ) where
1003            P: IsA<SocketClient>,
1004        {
1005            let f: &F = &*(f as *const F);
1006            f(&SocketClient::from_glib_borrow(this).unsafe_cast())
1007        }
1008        unsafe {
1009            let f: Box_<F> = Box_::new(f);
1010            connect_raw(
1011                self.as_ptr() as *mut _,
1012                b"notify::type\0".as_ptr() as *const _,
1013                Some(transmute(notify_type_trampoline::<Self, F> as usize)),
1014                Box_::into_raw(f),
1015            )
1016        }
1017    }
1018}
1019
1020impl fmt::Display for SocketClient {
1021    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1022        write!(f, "SocketClient")
1023    }
1024}