gio/auto/
unix_socket_address.rs1use gio_sys;
6use glib::object::IsA;
7use glib::translate::*;
8use glib::StaticType;
9use glib::Value;
10use gobject_sys;
11use std::fmt;
12use SocketAddress;
13use SocketConnectable;
14use UnixSocketAddressType;
15
16glib_wrapper! {
17 pub struct UnixSocketAddress(Object<gio_sys::GUnixSocketAddress, gio_sys::GUnixSocketAddressClass, UnixSocketAddressClass>) @extends SocketAddress, @implements SocketConnectable;
18
19 match fn {
20 get_type => || gio_sys::g_unix_socket_address_get_type(),
21 }
22}
23
24impl UnixSocketAddress {
25 pub fn abstract_names_supported() -> bool {
34 unsafe { from_glib(gio_sys::g_unix_socket_address_abstract_names_supported()) }
35 }
36}
37
38unsafe impl Send for UnixSocketAddress {}
39unsafe impl Sync for UnixSocketAddress {}
40
41pub const NONE_UNIX_SOCKET_ADDRESS: Option<&UnixSocketAddress> = None;
42
43pub trait UnixSocketAddressExt: 'static {
44 fn get_address_type(&self) -> UnixSocketAddressType;
45
46 fn get_is_abstract(&self) -> bool;
47
48 fn get_path_len(&self) -> usize;
49
50 fn get_property_abstract(&self) -> bool;
51
52 }
54
55impl<O: IsA<UnixSocketAddress>> UnixSocketAddressExt for O {
56 fn get_address_type(&self) -> UnixSocketAddressType {
57 unsafe {
58 from_glib(gio_sys::g_unix_socket_address_get_address_type(
59 self.as_ref().to_glib_none().0,
60 ))
61 }
62 }
63
64 fn get_is_abstract(&self) -> bool {
65 unsafe {
66 from_glib(gio_sys::g_unix_socket_address_get_is_abstract(
67 self.as_ref().to_glib_none().0,
68 ))
69 }
70 }
71
72 fn get_path_len(&self) -> usize {
73 unsafe { gio_sys::g_unix_socket_address_get_path_len(self.as_ref().to_glib_none().0) }
74 }
75
76 fn get_property_abstract(&self) -> bool {
77 unsafe {
78 let mut value = Value::from_type(<bool as StaticType>::static_type());
79 gobject_sys::g_object_get_property(
80 self.to_glib_none().0 as *mut gobject_sys::GObject,
81 b"abstract\0".as_ptr() as *const _,
82 value.to_glib_none_mut().0,
83 );
84 value.get().unwrap()
85 }
86 }
87
88 }
96
97impl fmt::Display for UnixSocketAddress {
98 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
99 write!(f, "UnixSocketAddress")
100 }
101}