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