gio/auto/
inet_address.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::object::Cast;
7use glib::object::IsA;
8use glib::signal::connect_raw;
9use glib::signal::SignalHandlerId;
10use glib::translate::*;
11use glib::GString;
12use glib_sys;
13use std::boxed::Box as Box_;
14use std::fmt;
15use std::mem::transmute;
16use SocketFamily;
17
18glib_wrapper! {
19    pub struct InetAddress(Object<gio_sys::GInetAddress, gio_sys::GInetAddressClass, InetAddressClass>);
20
21    match fn {
22        get_type => || gio_sys::g_inet_address_get_type(),
23    }
24}
25
26impl InetAddress {
27    pub fn new_any(family: SocketFamily) -> InetAddress {
28        unsafe { from_glib_full(gio_sys::g_inet_address_new_any(family.to_glib())) }
29    }
30
31    pub fn new_from_string(string: &str) -> InetAddress {
32        unsafe {
33            from_glib_full(gio_sys::g_inet_address_new_from_string(
34                string.to_glib_none().0,
35            ))
36        }
37    }
38
39    pub fn new_loopback(family: SocketFamily) -> InetAddress {
40        unsafe { from_glib_full(gio_sys::g_inet_address_new_loopback(family.to_glib())) }
41    }
42}
43
44unsafe impl Send for InetAddress {}
45unsafe impl Sync for InetAddress {}
46
47pub const NONE_INET_ADDRESS: Option<&InetAddress> = None;
48
49pub trait InetAddressExt: 'static {
50    fn equal<P: IsA<InetAddress>>(&self, other_address: &P) -> bool;
51
52    fn get_family(&self) -> SocketFamily;
53
54    fn get_is_any(&self) -> bool;
55
56    fn get_is_link_local(&self) -> bool;
57
58    fn get_is_loopback(&self) -> bool;
59
60    fn get_is_mc_global(&self) -> bool;
61
62    fn get_is_mc_link_local(&self) -> bool;
63
64    fn get_is_mc_node_local(&self) -> bool;
65
66    fn get_is_mc_org_local(&self) -> bool;
67
68    fn get_is_mc_site_local(&self) -> bool;
69
70    fn get_is_multicast(&self) -> bool;
71
72    fn get_is_site_local(&self) -> bool;
73
74    fn get_native_size(&self) -> usize;
75
76    fn to_string(&self) -> GString;
77
78    //fn get_property_bytes(&self) -> /*Unimplemented*/Fundamental: Pointer;
79
80    fn connect_property_is_any_notify<F: Fn(&Self) + Send + Sync + 'static>(
81        &self,
82        f: F,
83    ) -> SignalHandlerId;
84
85    fn connect_property_is_link_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
86        &self,
87        f: F,
88    ) -> SignalHandlerId;
89
90    fn connect_property_is_loopback_notify<F: Fn(&Self) + Send + Sync + 'static>(
91        &self,
92        f: F,
93    ) -> SignalHandlerId;
94
95    fn connect_property_is_mc_global_notify<F: Fn(&Self) + Send + Sync + 'static>(
96        &self,
97        f: F,
98    ) -> SignalHandlerId;
99
100    fn connect_property_is_mc_link_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
101        &self,
102        f: F,
103    ) -> SignalHandlerId;
104
105    fn connect_property_is_mc_node_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
106        &self,
107        f: F,
108    ) -> SignalHandlerId;
109
110    fn connect_property_is_mc_org_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
111        &self,
112        f: F,
113    ) -> SignalHandlerId;
114
115    fn connect_property_is_mc_site_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
116        &self,
117        f: F,
118    ) -> SignalHandlerId;
119
120    fn connect_property_is_multicast_notify<F: Fn(&Self) + Send + Sync + 'static>(
121        &self,
122        f: F,
123    ) -> SignalHandlerId;
124
125    fn connect_property_is_site_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
126        &self,
127        f: F,
128    ) -> SignalHandlerId;
129}
130
131impl<O: IsA<InetAddress>> InetAddressExt for O {
132    fn equal<P: IsA<InetAddress>>(&self, other_address: &P) -> bool {
133        unsafe {
134            from_glib(gio_sys::g_inet_address_equal(
135                self.as_ref().to_glib_none().0,
136                other_address.as_ref().to_glib_none().0,
137            ))
138        }
139    }
140
141    fn get_family(&self) -> SocketFamily {
142        unsafe {
143            from_glib(gio_sys::g_inet_address_get_family(
144                self.as_ref().to_glib_none().0,
145            ))
146        }
147    }
148
149    fn get_is_any(&self) -> bool {
150        unsafe {
151            from_glib(gio_sys::g_inet_address_get_is_any(
152                self.as_ref().to_glib_none().0,
153            ))
154        }
155    }
156
157    fn get_is_link_local(&self) -> bool {
158        unsafe {
159            from_glib(gio_sys::g_inet_address_get_is_link_local(
160                self.as_ref().to_glib_none().0,
161            ))
162        }
163    }
164
165    fn get_is_loopback(&self) -> bool {
166        unsafe {
167            from_glib(gio_sys::g_inet_address_get_is_loopback(
168                self.as_ref().to_glib_none().0,
169            ))
170        }
171    }
172
173    fn get_is_mc_global(&self) -> bool {
174        unsafe {
175            from_glib(gio_sys::g_inet_address_get_is_mc_global(
176                self.as_ref().to_glib_none().0,
177            ))
178        }
179    }
180
181    fn get_is_mc_link_local(&self) -> bool {
182        unsafe {
183            from_glib(gio_sys::g_inet_address_get_is_mc_link_local(
184                self.as_ref().to_glib_none().0,
185            ))
186        }
187    }
188
189    fn get_is_mc_node_local(&self) -> bool {
190        unsafe {
191            from_glib(gio_sys::g_inet_address_get_is_mc_node_local(
192                self.as_ref().to_glib_none().0,
193            ))
194        }
195    }
196
197    fn get_is_mc_org_local(&self) -> bool {
198        unsafe {
199            from_glib(gio_sys::g_inet_address_get_is_mc_org_local(
200                self.as_ref().to_glib_none().0,
201            ))
202        }
203    }
204
205    fn get_is_mc_site_local(&self) -> bool {
206        unsafe {
207            from_glib(gio_sys::g_inet_address_get_is_mc_site_local(
208                self.as_ref().to_glib_none().0,
209            ))
210        }
211    }
212
213    fn get_is_multicast(&self) -> bool {
214        unsafe {
215            from_glib(gio_sys::g_inet_address_get_is_multicast(
216                self.as_ref().to_glib_none().0,
217            ))
218        }
219    }
220
221    fn get_is_site_local(&self) -> bool {
222        unsafe {
223            from_glib(gio_sys::g_inet_address_get_is_site_local(
224                self.as_ref().to_glib_none().0,
225            ))
226        }
227    }
228
229    fn get_native_size(&self) -> usize {
230        unsafe { gio_sys::g_inet_address_get_native_size(self.as_ref().to_glib_none().0) }
231    }
232
233    fn to_string(&self) -> GString {
234        unsafe {
235            from_glib_full(gio_sys::g_inet_address_to_string(
236                self.as_ref().to_glib_none().0,
237            ))
238        }
239    }
240
241    //fn get_property_bytes(&self) -> /*Unimplemented*/Fundamental: Pointer {
242    //    unsafe {
243    //        let mut value = Value::from_type(</*Unknown type*/ as StaticType>::static_type());
244    //        gobject_sys::g_object_get_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"bytes\0".as_ptr() as *const _, value.to_glib_none_mut().0);
245    //        value.get().unwrap()
246    //    }
247    //}
248
249    fn connect_property_is_any_notify<F: Fn(&Self) + Send + Sync + 'static>(
250        &self,
251        f: F,
252    ) -> SignalHandlerId {
253        unsafe extern "C" fn notify_is_any_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
254            this: *mut gio_sys::GInetAddress,
255            _param_spec: glib_sys::gpointer,
256            f: glib_sys::gpointer,
257        ) where
258            P: IsA<InetAddress>,
259        {
260            let f: &F = &*(f as *const F);
261            f(&InetAddress::from_glib_borrow(this).unsafe_cast())
262        }
263        unsafe {
264            let f: Box_<F> = Box_::new(f);
265            connect_raw(
266                self.as_ptr() as *mut _,
267                b"notify::is-any\0".as_ptr() as *const _,
268                Some(transmute(notify_is_any_trampoline::<Self, F> as usize)),
269                Box_::into_raw(f),
270            )
271        }
272    }
273
274    fn connect_property_is_link_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
275        &self,
276        f: F,
277    ) -> SignalHandlerId {
278        unsafe extern "C" fn notify_is_link_local_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
279            this: *mut gio_sys::GInetAddress,
280            _param_spec: glib_sys::gpointer,
281            f: glib_sys::gpointer,
282        ) where
283            P: IsA<InetAddress>,
284        {
285            let f: &F = &*(f as *const F);
286            f(&InetAddress::from_glib_borrow(this).unsafe_cast())
287        }
288        unsafe {
289            let f: Box_<F> = Box_::new(f);
290            connect_raw(
291                self.as_ptr() as *mut _,
292                b"notify::is-link-local\0".as_ptr() as *const _,
293                Some(transmute(
294                    notify_is_link_local_trampoline::<Self, F> as usize,
295                )),
296                Box_::into_raw(f),
297            )
298        }
299    }
300
301    fn connect_property_is_loopback_notify<F: Fn(&Self) + Send + Sync + 'static>(
302        &self,
303        f: F,
304    ) -> SignalHandlerId {
305        unsafe extern "C" fn notify_is_loopback_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
306            this: *mut gio_sys::GInetAddress,
307            _param_spec: glib_sys::gpointer,
308            f: glib_sys::gpointer,
309        ) where
310            P: IsA<InetAddress>,
311        {
312            let f: &F = &*(f as *const F);
313            f(&InetAddress::from_glib_borrow(this).unsafe_cast())
314        }
315        unsafe {
316            let f: Box_<F> = Box_::new(f);
317            connect_raw(
318                self.as_ptr() as *mut _,
319                b"notify::is-loopback\0".as_ptr() as *const _,
320                Some(transmute(notify_is_loopback_trampoline::<Self, F> as usize)),
321                Box_::into_raw(f),
322            )
323        }
324    }
325
326    fn connect_property_is_mc_global_notify<F: Fn(&Self) + Send + Sync + 'static>(
327        &self,
328        f: F,
329    ) -> SignalHandlerId {
330        unsafe extern "C" fn notify_is_mc_global_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
331            this: *mut gio_sys::GInetAddress,
332            _param_spec: glib_sys::gpointer,
333            f: glib_sys::gpointer,
334        ) where
335            P: IsA<InetAddress>,
336        {
337            let f: &F = &*(f as *const F);
338            f(&InetAddress::from_glib_borrow(this).unsafe_cast())
339        }
340        unsafe {
341            let f: Box_<F> = Box_::new(f);
342            connect_raw(
343                self.as_ptr() as *mut _,
344                b"notify::is-mc-global\0".as_ptr() as *const _,
345                Some(transmute(
346                    notify_is_mc_global_trampoline::<Self, F> as usize,
347                )),
348                Box_::into_raw(f),
349            )
350        }
351    }
352
353    fn connect_property_is_mc_link_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
354        &self,
355        f: F,
356    ) -> SignalHandlerId {
357        unsafe extern "C" fn notify_is_mc_link_local_trampoline<
358            P,
359            F: Fn(&P) + Send + Sync + 'static,
360        >(
361            this: *mut gio_sys::GInetAddress,
362            _param_spec: glib_sys::gpointer,
363            f: glib_sys::gpointer,
364        ) where
365            P: IsA<InetAddress>,
366        {
367            let f: &F = &*(f as *const F);
368            f(&InetAddress::from_glib_borrow(this).unsafe_cast())
369        }
370        unsafe {
371            let f: Box_<F> = Box_::new(f);
372            connect_raw(
373                self.as_ptr() as *mut _,
374                b"notify::is-mc-link-local\0".as_ptr() as *const _,
375                Some(transmute(
376                    notify_is_mc_link_local_trampoline::<Self, F> as usize,
377                )),
378                Box_::into_raw(f),
379            )
380        }
381    }
382
383    fn connect_property_is_mc_node_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
384        &self,
385        f: F,
386    ) -> SignalHandlerId {
387        unsafe extern "C" fn notify_is_mc_node_local_trampoline<
388            P,
389            F: Fn(&P) + Send + Sync + 'static,
390        >(
391            this: *mut gio_sys::GInetAddress,
392            _param_spec: glib_sys::gpointer,
393            f: glib_sys::gpointer,
394        ) where
395            P: IsA<InetAddress>,
396        {
397            let f: &F = &*(f as *const F);
398            f(&InetAddress::from_glib_borrow(this).unsafe_cast())
399        }
400        unsafe {
401            let f: Box_<F> = Box_::new(f);
402            connect_raw(
403                self.as_ptr() as *mut _,
404                b"notify::is-mc-node-local\0".as_ptr() as *const _,
405                Some(transmute(
406                    notify_is_mc_node_local_trampoline::<Self, F> as usize,
407                )),
408                Box_::into_raw(f),
409            )
410        }
411    }
412
413    fn connect_property_is_mc_org_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
414        &self,
415        f: F,
416    ) -> SignalHandlerId {
417        unsafe extern "C" fn notify_is_mc_org_local_trampoline<
418            P,
419            F: Fn(&P) + Send + Sync + 'static,
420        >(
421            this: *mut gio_sys::GInetAddress,
422            _param_spec: glib_sys::gpointer,
423            f: glib_sys::gpointer,
424        ) where
425            P: IsA<InetAddress>,
426        {
427            let f: &F = &*(f as *const F);
428            f(&InetAddress::from_glib_borrow(this).unsafe_cast())
429        }
430        unsafe {
431            let f: Box_<F> = Box_::new(f);
432            connect_raw(
433                self.as_ptr() as *mut _,
434                b"notify::is-mc-org-local\0".as_ptr() as *const _,
435                Some(transmute(
436                    notify_is_mc_org_local_trampoline::<Self, F> as usize,
437                )),
438                Box_::into_raw(f),
439            )
440        }
441    }
442
443    fn connect_property_is_mc_site_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
444        &self,
445        f: F,
446    ) -> SignalHandlerId {
447        unsafe extern "C" fn notify_is_mc_site_local_trampoline<
448            P,
449            F: Fn(&P) + Send + Sync + 'static,
450        >(
451            this: *mut gio_sys::GInetAddress,
452            _param_spec: glib_sys::gpointer,
453            f: glib_sys::gpointer,
454        ) where
455            P: IsA<InetAddress>,
456        {
457            let f: &F = &*(f as *const F);
458            f(&InetAddress::from_glib_borrow(this).unsafe_cast())
459        }
460        unsafe {
461            let f: Box_<F> = Box_::new(f);
462            connect_raw(
463                self.as_ptr() as *mut _,
464                b"notify::is-mc-site-local\0".as_ptr() as *const _,
465                Some(transmute(
466                    notify_is_mc_site_local_trampoline::<Self, F> as usize,
467                )),
468                Box_::into_raw(f),
469            )
470        }
471    }
472
473    fn connect_property_is_multicast_notify<F: Fn(&Self) + Send + Sync + 'static>(
474        &self,
475        f: F,
476    ) -> SignalHandlerId {
477        unsafe extern "C" fn notify_is_multicast_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
478            this: *mut gio_sys::GInetAddress,
479            _param_spec: glib_sys::gpointer,
480            f: glib_sys::gpointer,
481        ) where
482            P: IsA<InetAddress>,
483        {
484            let f: &F = &*(f as *const F);
485            f(&InetAddress::from_glib_borrow(this).unsafe_cast())
486        }
487        unsafe {
488            let f: Box_<F> = Box_::new(f);
489            connect_raw(
490                self.as_ptr() as *mut _,
491                b"notify::is-multicast\0".as_ptr() as *const _,
492                Some(transmute(
493                    notify_is_multicast_trampoline::<Self, F> as usize,
494                )),
495                Box_::into_raw(f),
496            )
497        }
498    }
499
500    fn connect_property_is_site_local_notify<F: Fn(&Self) + Send + Sync + 'static>(
501        &self,
502        f: F,
503    ) -> SignalHandlerId {
504        unsafe extern "C" fn notify_is_site_local_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
505            this: *mut gio_sys::GInetAddress,
506            _param_spec: glib_sys::gpointer,
507            f: glib_sys::gpointer,
508        ) where
509            P: IsA<InetAddress>,
510        {
511            let f: &F = &*(f as *const F);
512            f(&InetAddress::from_glib_borrow(this).unsafe_cast())
513        }
514        unsafe {
515            let f: Box_<F> = Box_::new(f);
516            connect_raw(
517                self.as_ptr() as *mut _,
518                b"notify::is-site-local\0".as_ptr() as *const _,
519                Some(transmute(
520                    notify_is_site_local_trampoline::<Self, F> as usize,
521                )),
522                Box_::into_raw(f),
523            )
524        }
525    }
526}
527
528impl fmt::Display for InetAddress {
529    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
530        write!(f, "InetAddress")
531    }
532}