gio/auto/
socket_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_sys;
12use std::boxed::Box as Box_;
13use std::fmt;
14use std::mem::transmute;
15use SocketConnectable;
16use SocketFamily;
17
18glib_wrapper! {
19    pub struct SocketAddress(Object<gio_sys::GSocketAddress, gio_sys::GSocketAddressClass, SocketAddressClass>) @implements SocketConnectable;
20
21    match fn {
22        get_type => || gio_sys::g_socket_address_get_type(),
23    }
24}
25
26impl SocketAddress {
27    //pub fn new_from_native(native: /*Unimplemented*/Fundamental: Pointer, len: usize) -> SocketAddress {
28    //    unsafe { TODO: call gio_sys:g_socket_address_new_from_native() }
29    //}
30}
31
32unsafe impl Send for SocketAddress {}
33unsafe impl Sync for SocketAddress {}
34
35pub const NONE_SOCKET_ADDRESS: Option<&SocketAddress> = None;
36
37pub trait SocketAddressExt: 'static {
38    fn get_family(&self) -> SocketFamily;
39
40    fn get_native_size(&self) -> isize;
41
42    //fn to_native(&self, dest: /*Unimplemented*/Option<Fundamental: Pointer>, destlen: usize) -> Result<(), Error>;
43
44    fn connect_property_family_notify<F: Fn(&Self) + Send + Sync + 'static>(
45        &self,
46        f: F,
47    ) -> SignalHandlerId;
48}
49
50impl<O: IsA<SocketAddress>> SocketAddressExt for O {
51    fn get_family(&self) -> SocketFamily {
52        unsafe {
53            from_glib(gio_sys::g_socket_address_get_family(
54                self.as_ref().to_glib_none().0,
55            ))
56        }
57    }
58
59    fn get_native_size(&self) -> isize {
60        unsafe { gio_sys::g_socket_address_get_native_size(self.as_ref().to_glib_none().0) }
61    }
62
63    //fn to_native(&self, dest: /*Unimplemented*/Option<Fundamental: Pointer>, destlen: usize) -> Result<(), Error> {
64    //    unsafe { TODO: call gio_sys:g_socket_address_to_native() }
65    //}
66
67    fn connect_property_family_notify<F: Fn(&Self) + Send + Sync + 'static>(
68        &self,
69        f: F,
70    ) -> SignalHandlerId {
71        unsafe extern "C" fn notify_family_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
72            this: *mut gio_sys::GSocketAddress,
73            _param_spec: glib_sys::gpointer,
74            f: glib_sys::gpointer,
75        ) where
76            P: IsA<SocketAddress>,
77        {
78            let f: &F = &*(f as *const F);
79            f(&SocketAddress::from_glib_borrow(this).unsafe_cast())
80        }
81        unsafe {
82            let f: Box_<F> = Box_::new(f);
83            connect_raw(
84                self.as_ptr() as *mut _,
85                b"notify::family\0".as_ptr() as *const _,
86                Some(transmute(notify_family_trampoline::<Self, F> as usize)),
87                Box_::into_raw(f),
88            )
89        }
90    }
91}
92
93impl fmt::Display for SocketAddress {
94    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
95        write!(f, "SocketAddress")
96    }
97}