gio/auto/
socket.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
5use gio_sys;
6use glib;
7use glib::object::Cast;
8use glib::object::IsA;
9use glib::signal::connect_raw;
10use glib::signal::SignalHandlerId;
11use glib::translate::*;
12use glib::ObjectExt;
13use glib::StaticType;
14use glib::Value;
15use glib_sys;
16use gobject_sys;
17use std::boxed::Box as Box_;
18use std::fmt;
19use std::mem;
20use std::mem::transmute;
21use std::ptr;
22use Cancellable;
23use Credentials;
24use Error;
25use InetAddress;
26use SocketAddress;
27use SocketConnection;
28use SocketFamily;
29use SocketProtocol;
30use SocketType;
31
32glib_wrapper! {
33    pub struct Socket(Object<gio_sys::GSocket, gio_sys::GSocketClass, SocketClass>);
34
35    match fn {
36        get_type => || gio_sys::g_socket_get_type(),
37    }
38}
39
40impl Socket {
41    pub fn new(
42        family: SocketFamily,
43        type_: SocketType,
44        protocol: SocketProtocol,
45    ) -> Result<Socket, Error> {
46        unsafe {
47            let mut error = ptr::null_mut();
48            let ret = gio_sys::g_socket_new(
49                family.to_glib(),
50                type_.to_glib(),
51                protocol.to_glib(),
52                &mut error,
53            );
54            if error.is_null() {
55                Ok(from_glib_full(ret))
56            } else {
57                Err(from_glib_full(error))
58            }
59        }
60    }
61}
62
63unsafe impl glib::SendUnique for Socket {
64    fn is_unique(&self) -> bool {
65        self.ref_count() == 1
66    }
67}
68
69pub const NONE_SOCKET: Option<&Socket> = None;
70
71pub trait SocketExt: 'static {
72    fn accept<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<Socket, Error>;
73
74    fn bind<P: IsA<SocketAddress>>(&self, address: &P, allow_reuse: bool) -> Result<(), Error>;
75
76    fn check_connect_result(&self) -> Result<(), Error>;
77
78    fn close(&self) -> Result<(), Error>;
79
80    fn condition_check(&self, condition: glib::IOCondition) -> glib::IOCondition;
81
82    fn condition_timed_wait<P: IsA<Cancellable>>(
83        &self,
84        condition: glib::IOCondition,
85        timeout: i64,
86        cancellable: Option<&P>,
87    ) -> Result<(), Error>;
88
89    fn condition_wait<P: IsA<Cancellable>>(
90        &self,
91        condition: glib::IOCondition,
92        cancellable: Option<&P>,
93    ) -> Result<(), Error>;
94
95    fn connect<P: IsA<SocketAddress>, Q: IsA<Cancellable>>(
96        &self,
97        address: &P,
98        cancellable: Option<&Q>,
99    ) -> Result<(), Error>;
100
101    fn connection_factory_create_connection(&self) -> Option<SocketConnection>;
102
103    fn get_available_bytes(&self) -> isize;
104
105    fn get_blocking(&self) -> bool;
106
107    fn get_broadcast(&self) -> bool;
108
109    fn get_credentials(&self) -> Result<Credentials, Error>;
110
111    fn get_family(&self) -> SocketFamily;
112
113    fn get_keepalive(&self) -> bool;
114
115    fn get_listen_backlog(&self) -> i32;
116
117    fn get_local_address(&self) -> Result<SocketAddress, Error>;
118
119    fn get_multicast_loopback(&self) -> bool;
120
121    fn get_multicast_ttl(&self) -> u32;
122
123    fn get_option(&self, level: i32, optname: i32) -> Result<i32, Error>;
124
125    fn get_protocol(&self) -> SocketProtocol;
126
127    fn get_remote_address(&self) -> Result<SocketAddress, Error>;
128
129    fn get_socket_type(&self) -> SocketType;
130
131    fn get_timeout(&self) -> u32;
132
133    fn get_ttl(&self) -> u32;
134
135    fn is_closed(&self) -> bool;
136
137    fn is_connected(&self) -> bool;
138
139    fn join_multicast_group<P: IsA<InetAddress>>(
140        &self,
141        group: &P,
142        source_specific: bool,
143        iface: Option<&str>,
144    ) -> Result<(), Error>;
145
146    #[cfg(any(feature = "v2_56", feature = "dox"))]
147    fn join_multicast_group_ssm<P: IsA<InetAddress>, Q: IsA<InetAddress>>(
148        &self,
149        group: &P,
150        source_specific: Option<&Q>,
151        iface: Option<&str>,
152    ) -> Result<(), Error>;
153
154    fn leave_multicast_group<P: IsA<InetAddress>>(
155        &self,
156        group: &P,
157        source_specific: bool,
158        iface: Option<&str>,
159    ) -> Result<(), Error>;
160
161    #[cfg(any(feature = "v2_56", feature = "dox"))]
162    fn leave_multicast_group_ssm<P: IsA<InetAddress>, Q: IsA<InetAddress>>(
163        &self,
164        group: &P,
165        source_specific: Option<&Q>,
166        iface: Option<&str>,
167    ) -> Result<(), Error>;
168
169    fn listen(&self) -> Result<(), Error>;
170
171    fn set_blocking(&self, blocking: bool);
172
173    fn set_broadcast(&self, broadcast: bool);
174
175    fn set_keepalive(&self, keepalive: bool);
176
177    fn set_listen_backlog(&self, backlog: i32);
178
179    fn set_multicast_loopback(&self, loopback: bool);
180
181    fn set_multicast_ttl(&self, ttl: u32);
182
183    fn set_option(&self, level: i32, optname: i32, value: i32) -> Result<(), Error>;
184
185    fn set_timeout(&self, timeout: u32);
186
187    fn set_ttl(&self, ttl: u32);
188
189    fn shutdown(&self, shutdown_read: bool, shutdown_write: bool) -> Result<(), Error>;
190
191    fn speaks_ipv4(&self) -> bool;
192
193    fn get_property_type(&self) -> SocketType;
194
195    fn connect_property_blocking_notify<F: Fn(&Self) + Send + 'static>(
196        &self,
197        f: F,
198    ) -> SignalHandlerId;
199
200    fn connect_property_broadcast_notify<F: Fn(&Self) + Send + 'static>(
201        &self,
202        f: F,
203    ) -> SignalHandlerId;
204
205    fn connect_property_keepalive_notify<F: Fn(&Self) + Send + 'static>(
206        &self,
207        f: F,
208    ) -> SignalHandlerId;
209
210    fn connect_property_listen_backlog_notify<F: Fn(&Self) + Send + 'static>(
211        &self,
212        f: F,
213    ) -> SignalHandlerId;
214
215    fn connect_property_local_address_notify<F: Fn(&Self) + Send + 'static>(
216        &self,
217        f: F,
218    ) -> SignalHandlerId;
219
220    fn connect_property_multicast_loopback_notify<F: Fn(&Self) + Send + 'static>(
221        &self,
222        f: F,
223    ) -> SignalHandlerId;
224
225    fn connect_property_multicast_ttl_notify<F: Fn(&Self) + Send + 'static>(
226        &self,
227        f: F,
228    ) -> SignalHandlerId;
229
230    fn connect_property_remote_address_notify<F: Fn(&Self) + Send + 'static>(
231        &self,
232        f: F,
233    ) -> SignalHandlerId;
234
235    fn connect_property_timeout_notify<F: Fn(&Self) + Send + 'static>(
236        &self,
237        f: F,
238    ) -> SignalHandlerId;
239
240    fn connect_property_ttl_notify<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId;
241}
242
243impl<O: IsA<Socket>> SocketExt for O {
244    fn accept<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<Socket, Error> {
245        unsafe {
246            let mut error = ptr::null_mut();
247            let ret = gio_sys::g_socket_accept(
248                self.as_ref().to_glib_none().0,
249                cancellable.map(|p| p.as_ref()).to_glib_none().0,
250                &mut error,
251            );
252            if error.is_null() {
253                Ok(from_glib_full(ret))
254            } else {
255                Err(from_glib_full(error))
256            }
257        }
258    }
259
260    fn bind<P: IsA<SocketAddress>>(&self, address: &P, allow_reuse: bool) -> Result<(), Error> {
261        unsafe {
262            let mut error = ptr::null_mut();
263            let _ = gio_sys::g_socket_bind(
264                self.as_ref().to_glib_none().0,
265                address.as_ref().to_glib_none().0,
266                allow_reuse.to_glib(),
267                &mut error,
268            );
269            if error.is_null() {
270                Ok(())
271            } else {
272                Err(from_glib_full(error))
273            }
274        }
275    }
276
277    fn check_connect_result(&self) -> Result<(), Error> {
278        unsafe {
279            let mut error = ptr::null_mut();
280            let _ =
281                gio_sys::g_socket_check_connect_result(self.as_ref().to_glib_none().0, &mut error);
282            if error.is_null() {
283                Ok(())
284            } else {
285                Err(from_glib_full(error))
286            }
287        }
288    }
289
290    fn close(&self) -> Result<(), Error> {
291        unsafe {
292            let mut error = ptr::null_mut();
293            let _ = gio_sys::g_socket_close(self.as_ref().to_glib_none().0, &mut error);
294            if error.is_null() {
295                Ok(())
296            } else {
297                Err(from_glib_full(error))
298            }
299        }
300    }
301
302    fn condition_check(&self, condition: glib::IOCondition) -> glib::IOCondition {
303        unsafe {
304            from_glib(gio_sys::g_socket_condition_check(
305                self.as_ref().to_glib_none().0,
306                condition.to_glib(),
307            ))
308        }
309    }
310
311    fn condition_timed_wait<P: IsA<Cancellable>>(
312        &self,
313        condition: glib::IOCondition,
314        timeout: i64,
315        cancellable: Option<&P>,
316    ) -> Result<(), Error> {
317        unsafe {
318            let mut error = ptr::null_mut();
319            let _ = gio_sys::g_socket_condition_timed_wait(
320                self.as_ref().to_glib_none().0,
321                condition.to_glib(),
322                timeout,
323                cancellable.map(|p| p.as_ref()).to_glib_none().0,
324                &mut error,
325            );
326            if error.is_null() {
327                Ok(())
328            } else {
329                Err(from_glib_full(error))
330            }
331        }
332    }
333
334    fn condition_wait<P: IsA<Cancellable>>(
335        &self,
336        condition: glib::IOCondition,
337        cancellable: Option<&P>,
338    ) -> Result<(), Error> {
339        unsafe {
340            let mut error = ptr::null_mut();
341            let _ = gio_sys::g_socket_condition_wait(
342                self.as_ref().to_glib_none().0,
343                condition.to_glib(),
344                cancellable.map(|p| p.as_ref()).to_glib_none().0,
345                &mut error,
346            );
347            if error.is_null() {
348                Ok(())
349            } else {
350                Err(from_glib_full(error))
351            }
352        }
353    }
354
355    fn connect<P: IsA<SocketAddress>, Q: IsA<Cancellable>>(
356        &self,
357        address: &P,
358        cancellable: Option<&Q>,
359    ) -> Result<(), Error> {
360        unsafe {
361            let mut error = ptr::null_mut();
362            let _ = gio_sys::g_socket_connect(
363                self.as_ref().to_glib_none().0,
364                address.as_ref().to_glib_none().0,
365                cancellable.map(|p| p.as_ref()).to_glib_none().0,
366                &mut error,
367            );
368            if error.is_null() {
369                Ok(())
370            } else {
371                Err(from_glib_full(error))
372            }
373        }
374    }
375
376    fn connection_factory_create_connection(&self) -> Option<SocketConnection> {
377        unsafe {
378            from_glib_full(gio_sys::g_socket_connection_factory_create_connection(
379                self.as_ref().to_glib_none().0,
380            ))
381        }
382    }
383
384    fn get_available_bytes(&self) -> isize {
385        unsafe { gio_sys::g_socket_get_available_bytes(self.as_ref().to_glib_none().0) }
386    }
387
388    fn get_blocking(&self) -> bool {
389        unsafe {
390            from_glib(gio_sys::g_socket_get_blocking(
391                self.as_ref().to_glib_none().0,
392            ))
393        }
394    }
395
396    fn get_broadcast(&self) -> bool {
397        unsafe {
398            from_glib(gio_sys::g_socket_get_broadcast(
399                self.as_ref().to_glib_none().0,
400            ))
401        }
402    }
403
404    fn get_credentials(&self) -> Result<Credentials, Error> {
405        unsafe {
406            let mut error = ptr::null_mut();
407            let ret = gio_sys::g_socket_get_credentials(self.as_ref().to_glib_none().0, &mut error);
408            if error.is_null() {
409                Ok(from_glib_full(ret))
410            } else {
411                Err(from_glib_full(error))
412            }
413        }
414    }
415
416    fn get_family(&self) -> SocketFamily {
417        unsafe { from_glib(gio_sys::g_socket_get_family(self.as_ref().to_glib_none().0)) }
418    }
419
420    fn get_keepalive(&self) -> bool {
421        unsafe {
422            from_glib(gio_sys::g_socket_get_keepalive(
423                self.as_ref().to_glib_none().0,
424            ))
425        }
426    }
427
428    fn get_listen_backlog(&self) -> i32 {
429        unsafe { gio_sys::g_socket_get_listen_backlog(self.as_ref().to_glib_none().0) }
430    }
431
432    fn get_local_address(&self) -> Result<SocketAddress, Error> {
433        unsafe {
434            let mut error = ptr::null_mut();
435            let ret =
436                gio_sys::g_socket_get_local_address(self.as_ref().to_glib_none().0, &mut error);
437            if error.is_null() {
438                Ok(from_glib_full(ret))
439            } else {
440                Err(from_glib_full(error))
441            }
442        }
443    }
444
445    fn get_multicast_loopback(&self) -> bool {
446        unsafe {
447            from_glib(gio_sys::g_socket_get_multicast_loopback(
448                self.as_ref().to_glib_none().0,
449            ))
450        }
451    }
452
453    fn get_multicast_ttl(&self) -> u32 {
454        unsafe { gio_sys::g_socket_get_multicast_ttl(self.as_ref().to_glib_none().0) }
455    }
456
457    fn get_option(&self, level: i32, optname: i32) -> Result<i32, Error> {
458        unsafe {
459            let mut value = mem::uninitialized();
460            let mut error = ptr::null_mut();
461            let _ = gio_sys::g_socket_get_option(
462                self.as_ref().to_glib_none().0,
463                level,
464                optname,
465                &mut value,
466                &mut error,
467            );
468            if error.is_null() {
469                Ok(value)
470            } else {
471                Err(from_glib_full(error))
472            }
473        }
474    }
475
476    fn get_protocol(&self) -> SocketProtocol {
477        unsafe {
478            from_glib(gio_sys::g_socket_get_protocol(
479                self.as_ref().to_glib_none().0,
480            ))
481        }
482    }
483
484    fn get_remote_address(&self) -> Result<SocketAddress, Error> {
485        unsafe {
486            let mut error = ptr::null_mut();
487            let ret =
488                gio_sys::g_socket_get_remote_address(self.as_ref().to_glib_none().0, &mut error);
489            if error.is_null() {
490                Ok(from_glib_full(ret))
491            } else {
492                Err(from_glib_full(error))
493            }
494        }
495    }
496
497    fn get_socket_type(&self) -> SocketType {
498        unsafe {
499            from_glib(gio_sys::g_socket_get_socket_type(
500                self.as_ref().to_glib_none().0,
501            ))
502        }
503    }
504
505    fn get_timeout(&self) -> u32 {
506        unsafe { gio_sys::g_socket_get_timeout(self.as_ref().to_glib_none().0) }
507    }
508
509    fn get_ttl(&self) -> u32 {
510        unsafe { gio_sys::g_socket_get_ttl(self.as_ref().to_glib_none().0) }
511    }
512
513    fn is_closed(&self) -> bool {
514        unsafe { from_glib(gio_sys::g_socket_is_closed(self.as_ref().to_glib_none().0)) }
515    }
516
517    fn is_connected(&self) -> bool {
518        unsafe {
519            from_glib(gio_sys::g_socket_is_connected(
520                self.as_ref().to_glib_none().0,
521            ))
522        }
523    }
524
525    fn join_multicast_group<P: IsA<InetAddress>>(
526        &self,
527        group: &P,
528        source_specific: bool,
529        iface: Option<&str>,
530    ) -> Result<(), Error> {
531        unsafe {
532            let mut error = ptr::null_mut();
533            let _ = gio_sys::g_socket_join_multicast_group(
534                self.as_ref().to_glib_none().0,
535                group.as_ref().to_glib_none().0,
536                source_specific.to_glib(),
537                iface.to_glib_none().0,
538                &mut error,
539            );
540            if error.is_null() {
541                Ok(())
542            } else {
543                Err(from_glib_full(error))
544            }
545        }
546    }
547
548    #[cfg(any(feature = "v2_56", feature = "dox"))]
549    fn join_multicast_group_ssm<P: IsA<InetAddress>, Q: IsA<InetAddress>>(
550        &self,
551        group: &P,
552        source_specific: Option<&Q>,
553        iface: Option<&str>,
554    ) -> Result<(), Error> {
555        unsafe {
556            let mut error = ptr::null_mut();
557            let _ = gio_sys::g_socket_join_multicast_group_ssm(
558                self.as_ref().to_glib_none().0,
559                group.as_ref().to_glib_none().0,
560                source_specific.map(|p| p.as_ref()).to_glib_none().0,
561                iface.to_glib_none().0,
562                &mut error,
563            );
564            if error.is_null() {
565                Ok(())
566            } else {
567                Err(from_glib_full(error))
568            }
569        }
570    }
571
572    fn leave_multicast_group<P: IsA<InetAddress>>(
573        &self,
574        group: &P,
575        source_specific: bool,
576        iface: Option<&str>,
577    ) -> Result<(), Error> {
578        unsafe {
579            let mut error = ptr::null_mut();
580            let _ = gio_sys::g_socket_leave_multicast_group(
581                self.as_ref().to_glib_none().0,
582                group.as_ref().to_glib_none().0,
583                source_specific.to_glib(),
584                iface.to_glib_none().0,
585                &mut error,
586            );
587            if error.is_null() {
588                Ok(())
589            } else {
590                Err(from_glib_full(error))
591            }
592        }
593    }
594
595    #[cfg(any(feature = "v2_56", feature = "dox"))]
596    fn leave_multicast_group_ssm<P: IsA<InetAddress>, Q: IsA<InetAddress>>(
597        &self,
598        group: &P,
599        source_specific: Option<&Q>,
600        iface: Option<&str>,
601    ) -> Result<(), Error> {
602        unsafe {
603            let mut error = ptr::null_mut();
604            let _ = gio_sys::g_socket_leave_multicast_group_ssm(
605                self.as_ref().to_glib_none().0,
606                group.as_ref().to_glib_none().0,
607                source_specific.map(|p| p.as_ref()).to_glib_none().0,
608                iface.to_glib_none().0,
609                &mut error,
610            );
611            if error.is_null() {
612                Ok(())
613            } else {
614                Err(from_glib_full(error))
615            }
616        }
617    }
618
619    fn listen(&self) -> Result<(), Error> {
620        unsafe {
621            let mut error = ptr::null_mut();
622            let _ = gio_sys::g_socket_listen(self.as_ref().to_glib_none().0, &mut error);
623            if error.is_null() {
624                Ok(())
625            } else {
626                Err(from_glib_full(error))
627            }
628        }
629    }
630
631    fn set_blocking(&self, blocking: bool) {
632        unsafe {
633            gio_sys::g_socket_set_blocking(self.as_ref().to_glib_none().0, blocking.to_glib());
634        }
635    }
636
637    fn set_broadcast(&self, broadcast: bool) {
638        unsafe {
639            gio_sys::g_socket_set_broadcast(self.as_ref().to_glib_none().0, broadcast.to_glib());
640        }
641    }
642
643    fn set_keepalive(&self, keepalive: bool) {
644        unsafe {
645            gio_sys::g_socket_set_keepalive(self.as_ref().to_glib_none().0, keepalive.to_glib());
646        }
647    }
648
649    fn set_listen_backlog(&self, backlog: i32) {
650        unsafe {
651            gio_sys::g_socket_set_listen_backlog(self.as_ref().to_glib_none().0, backlog);
652        }
653    }
654
655    fn set_multicast_loopback(&self, loopback: bool) {
656        unsafe {
657            gio_sys::g_socket_set_multicast_loopback(
658                self.as_ref().to_glib_none().0,
659                loopback.to_glib(),
660            );
661        }
662    }
663
664    fn set_multicast_ttl(&self, ttl: u32) {
665        unsafe {
666            gio_sys::g_socket_set_multicast_ttl(self.as_ref().to_glib_none().0, ttl);
667        }
668    }
669
670    fn set_option(&self, level: i32, optname: i32, value: i32) -> Result<(), Error> {
671        unsafe {
672            let mut error = ptr::null_mut();
673            let _ = gio_sys::g_socket_set_option(
674                self.as_ref().to_glib_none().0,
675                level,
676                optname,
677                value,
678                &mut error,
679            );
680            if error.is_null() {
681                Ok(())
682            } else {
683                Err(from_glib_full(error))
684            }
685        }
686    }
687
688    fn set_timeout(&self, timeout: u32) {
689        unsafe {
690            gio_sys::g_socket_set_timeout(self.as_ref().to_glib_none().0, timeout);
691        }
692    }
693
694    fn set_ttl(&self, ttl: u32) {
695        unsafe {
696            gio_sys::g_socket_set_ttl(self.as_ref().to_glib_none().0, ttl);
697        }
698    }
699
700    fn shutdown(&self, shutdown_read: bool, shutdown_write: bool) -> Result<(), Error> {
701        unsafe {
702            let mut error = ptr::null_mut();
703            let _ = gio_sys::g_socket_shutdown(
704                self.as_ref().to_glib_none().0,
705                shutdown_read.to_glib(),
706                shutdown_write.to_glib(),
707                &mut error,
708            );
709            if error.is_null() {
710                Ok(())
711            } else {
712                Err(from_glib_full(error))
713            }
714        }
715    }
716
717    fn speaks_ipv4(&self) -> bool {
718        unsafe {
719            from_glib(gio_sys::g_socket_speaks_ipv4(
720                self.as_ref().to_glib_none().0,
721            ))
722        }
723    }
724
725    fn get_property_type(&self) -> SocketType {
726        unsafe {
727            let mut value = Value::from_type(<SocketType as StaticType>::static_type());
728            gobject_sys::g_object_get_property(
729                self.to_glib_none().0 as *mut gobject_sys::GObject,
730                b"type\0".as_ptr() as *const _,
731                value.to_glib_none_mut().0,
732            );
733            value.get().unwrap()
734        }
735    }
736
737    fn connect_property_blocking_notify<F: Fn(&Self) + Send + 'static>(
738        &self,
739        f: F,
740    ) -> SignalHandlerId {
741        unsafe extern "C" fn notify_blocking_trampoline<P, F: Fn(&P) + Send + 'static>(
742            this: *mut gio_sys::GSocket,
743            _param_spec: glib_sys::gpointer,
744            f: glib_sys::gpointer,
745        ) where
746            P: IsA<Socket>,
747        {
748            let f: &F = &*(f as *const F);
749            f(&Socket::from_glib_borrow(this).unsafe_cast())
750        }
751        unsafe {
752            let f: Box_<F> = Box_::new(f);
753            connect_raw(
754                self.as_ptr() as *mut _,
755                b"notify::blocking\0".as_ptr() as *const _,
756                Some(transmute(notify_blocking_trampoline::<Self, F> as usize)),
757                Box_::into_raw(f),
758            )
759        }
760    }
761
762    fn connect_property_broadcast_notify<F: Fn(&Self) + Send + 'static>(
763        &self,
764        f: F,
765    ) -> SignalHandlerId {
766        unsafe extern "C" fn notify_broadcast_trampoline<P, F: Fn(&P) + Send + 'static>(
767            this: *mut gio_sys::GSocket,
768            _param_spec: glib_sys::gpointer,
769            f: glib_sys::gpointer,
770        ) where
771            P: IsA<Socket>,
772        {
773            let f: &F = &*(f as *const F);
774            f(&Socket::from_glib_borrow(this).unsafe_cast())
775        }
776        unsafe {
777            let f: Box_<F> = Box_::new(f);
778            connect_raw(
779                self.as_ptr() as *mut _,
780                b"notify::broadcast\0".as_ptr() as *const _,
781                Some(transmute(notify_broadcast_trampoline::<Self, F> as usize)),
782                Box_::into_raw(f),
783            )
784        }
785    }
786
787    fn connect_property_keepalive_notify<F: Fn(&Self) + Send + 'static>(
788        &self,
789        f: F,
790    ) -> SignalHandlerId {
791        unsafe extern "C" fn notify_keepalive_trampoline<P, F: Fn(&P) + Send + 'static>(
792            this: *mut gio_sys::GSocket,
793            _param_spec: glib_sys::gpointer,
794            f: glib_sys::gpointer,
795        ) where
796            P: IsA<Socket>,
797        {
798            let f: &F = &*(f as *const F);
799            f(&Socket::from_glib_borrow(this).unsafe_cast())
800        }
801        unsafe {
802            let f: Box_<F> = Box_::new(f);
803            connect_raw(
804                self.as_ptr() as *mut _,
805                b"notify::keepalive\0".as_ptr() as *const _,
806                Some(transmute(notify_keepalive_trampoline::<Self, F> as usize)),
807                Box_::into_raw(f),
808            )
809        }
810    }
811
812    fn connect_property_listen_backlog_notify<F: Fn(&Self) + Send + 'static>(
813        &self,
814        f: F,
815    ) -> SignalHandlerId {
816        unsafe extern "C" fn notify_listen_backlog_trampoline<P, F: Fn(&P) + Send + 'static>(
817            this: *mut gio_sys::GSocket,
818            _param_spec: glib_sys::gpointer,
819            f: glib_sys::gpointer,
820        ) where
821            P: IsA<Socket>,
822        {
823            let f: &F = &*(f as *const F);
824            f(&Socket::from_glib_borrow(this).unsafe_cast())
825        }
826        unsafe {
827            let f: Box_<F> = Box_::new(f);
828            connect_raw(
829                self.as_ptr() as *mut _,
830                b"notify::listen-backlog\0".as_ptr() as *const _,
831                Some(transmute(
832                    notify_listen_backlog_trampoline::<Self, F> as usize,
833                )),
834                Box_::into_raw(f),
835            )
836        }
837    }
838
839    fn connect_property_local_address_notify<F: Fn(&Self) + Send + 'static>(
840        &self,
841        f: F,
842    ) -> SignalHandlerId {
843        unsafe extern "C" fn notify_local_address_trampoline<P, F: Fn(&P) + Send + 'static>(
844            this: *mut gio_sys::GSocket,
845            _param_spec: glib_sys::gpointer,
846            f: glib_sys::gpointer,
847        ) where
848            P: IsA<Socket>,
849        {
850            let f: &F = &*(f as *const F);
851            f(&Socket::from_glib_borrow(this).unsafe_cast())
852        }
853        unsafe {
854            let f: Box_<F> = Box_::new(f);
855            connect_raw(
856                self.as_ptr() as *mut _,
857                b"notify::local-address\0".as_ptr() as *const _,
858                Some(transmute(
859                    notify_local_address_trampoline::<Self, F> as usize,
860                )),
861                Box_::into_raw(f),
862            )
863        }
864    }
865
866    fn connect_property_multicast_loopback_notify<F: Fn(&Self) + Send + 'static>(
867        &self,
868        f: F,
869    ) -> SignalHandlerId {
870        unsafe extern "C" fn notify_multicast_loopback_trampoline<P, F: Fn(&P) + Send + 'static>(
871            this: *mut gio_sys::GSocket,
872            _param_spec: glib_sys::gpointer,
873            f: glib_sys::gpointer,
874        ) where
875            P: IsA<Socket>,
876        {
877            let f: &F = &*(f as *const F);
878            f(&Socket::from_glib_borrow(this).unsafe_cast())
879        }
880        unsafe {
881            let f: Box_<F> = Box_::new(f);
882            connect_raw(
883                self.as_ptr() as *mut _,
884                b"notify::multicast-loopback\0".as_ptr() as *const _,
885                Some(transmute(
886                    notify_multicast_loopback_trampoline::<Self, F> as usize,
887                )),
888                Box_::into_raw(f),
889            )
890        }
891    }
892
893    fn connect_property_multicast_ttl_notify<F: Fn(&Self) + Send + 'static>(
894        &self,
895        f: F,
896    ) -> SignalHandlerId {
897        unsafe extern "C" fn notify_multicast_ttl_trampoline<P, F: Fn(&P) + Send + 'static>(
898            this: *mut gio_sys::GSocket,
899            _param_spec: glib_sys::gpointer,
900            f: glib_sys::gpointer,
901        ) where
902            P: IsA<Socket>,
903        {
904            let f: &F = &*(f as *const F);
905            f(&Socket::from_glib_borrow(this).unsafe_cast())
906        }
907        unsafe {
908            let f: Box_<F> = Box_::new(f);
909            connect_raw(
910                self.as_ptr() as *mut _,
911                b"notify::multicast-ttl\0".as_ptr() as *const _,
912                Some(transmute(
913                    notify_multicast_ttl_trampoline::<Self, F> as usize,
914                )),
915                Box_::into_raw(f),
916            )
917        }
918    }
919
920    fn connect_property_remote_address_notify<F: Fn(&Self) + Send + 'static>(
921        &self,
922        f: F,
923    ) -> SignalHandlerId {
924        unsafe extern "C" fn notify_remote_address_trampoline<P, F: Fn(&P) + Send + 'static>(
925            this: *mut gio_sys::GSocket,
926            _param_spec: glib_sys::gpointer,
927            f: glib_sys::gpointer,
928        ) where
929            P: IsA<Socket>,
930        {
931            let f: &F = &*(f as *const F);
932            f(&Socket::from_glib_borrow(this).unsafe_cast())
933        }
934        unsafe {
935            let f: Box_<F> = Box_::new(f);
936            connect_raw(
937                self.as_ptr() as *mut _,
938                b"notify::remote-address\0".as_ptr() as *const _,
939                Some(transmute(
940                    notify_remote_address_trampoline::<Self, F> as usize,
941                )),
942                Box_::into_raw(f),
943            )
944        }
945    }
946
947    fn connect_property_timeout_notify<F: Fn(&Self) + Send + 'static>(
948        &self,
949        f: F,
950    ) -> SignalHandlerId {
951        unsafe extern "C" fn notify_timeout_trampoline<P, F: Fn(&P) + Send + 'static>(
952            this: *mut gio_sys::GSocket,
953            _param_spec: glib_sys::gpointer,
954            f: glib_sys::gpointer,
955        ) where
956            P: IsA<Socket>,
957        {
958            let f: &F = &*(f as *const F);
959            f(&Socket::from_glib_borrow(this).unsafe_cast())
960        }
961        unsafe {
962            let f: Box_<F> = Box_::new(f);
963            connect_raw(
964                self.as_ptr() as *mut _,
965                b"notify::timeout\0".as_ptr() as *const _,
966                Some(transmute(notify_timeout_trampoline::<Self, F> as usize)),
967                Box_::into_raw(f),
968            )
969        }
970    }
971
972    fn connect_property_ttl_notify<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
973        unsafe extern "C" fn notify_ttl_trampoline<P, F: Fn(&P) + Send + 'static>(
974            this: *mut gio_sys::GSocket,
975            _param_spec: glib_sys::gpointer,
976            f: glib_sys::gpointer,
977        ) where
978            P: IsA<Socket>,
979        {
980            let f: &F = &*(f as *const F);
981            f(&Socket::from_glib_borrow(this).unsafe_cast())
982        }
983        unsafe {
984            let f: Box_<F> = Box_::new(f);
985            connect_raw(
986                self.as_ptr() as *mut _,
987                b"notify::ttl\0".as_ptr() as *const _,
988                Some(transmute(notify_ttl_trampoline::<Self, F> as usize)),
989                Box_::into_raw(f),
990            )
991        }
992    }
993}
994
995impl fmt::Display for Socket {
996    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
997        write!(f, "Socket")
998    }
999}