gio/auto/
unix_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 crate::{ffi, SocketAddress, SocketConnectable, UnixSocketAddressType};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// Support for UNIX-domain (also known as local) sockets, corresponding to
10    /// `struct sockaddr_un`.
11    ///
12    /// UNIX domain sockets are generally visible in the filesystem.
13    /// However, some systems support abstract socket names which are not
14    /// visible in the filesystem and not affected by the filesystem
15    /// permissions, visibility, etc. Currently this is only supported
16    /// under Linux. If you attempt to use abstract sockets on other
17    /// systems, function calls may return `G_IO_ERROR_NOT_SUPPORTED`
18    /// errors. You can use [`abstract_names_supported()`][Self::abstract_names_supported()]
19    /// to see if abstract names are supported.
20    ///
21    /// Since GLib 2.72, `GUnixSocketAddress` is available on all platforms. It
22    /// requires underlying system support (such as Windows 10 with `AF_UNIX`) at
23    /// run time.
24    ///
25    /// Before GLib 2.72, `<gio/gunixsocketaddress.h>` belonged to the UNIX-specific
26    /// GIO interfaces, thus you had to use the `gio-unix-2.0.pc` pkg-config file
27    /// when using it. This is no longer necessary since GLib 2.72.
28    ///
29    /// ## Properties
30    ///
31    ///
32    /// #### `abstract`
33    ///  Whether or not this is an abstract address
34    ///
35    /// Readable | Writeable | Construct Only
36    ///
37    ///
38    /// #### `address-type`
39    ///  The type of Unix socket address.
40    ///
41    /// Readable | Writeable | Construct Only
42    ///
43    ///
44    /// #### `path`
45    ///  Unix socket path.
46    ///
47    /// Readable | Writeable | Construct Only
48    ///
49    ///
50    /// #### `path-as-array`
51    ///  Unix socket path, as a byte array.
52    ///
53    /// Readable | Writeable | Construct Only
54    /// <details><summary><h4>SocketAddress</h4></summary>
55    ///
56    ///
57    /// #### `family`
58    ///  The family of the socket address.
59    ///
60    /// Readable
61    /// </details>
62    ///
63    /// # Implements
64    ///
65    /// [`UnixSocketAddressExt`][trait@crate::prelude::UnixSocketAddressExt], [`SocketAddressExt`][trait@crate::prelude::SocketAddressExt], [`trait@glib::ObjectExt`], [`SocketConnectableExt`][trait@crate::prelude::SocketConnectableExt], [`UnixSocketAddressExtManual`][trait@crate::prelude::UnixSocketAddressExtManual]
66    #[doc(alias = "GUnixSocketAddress")]
67    pub struct UnixSocketAddress(Object<ffi::GUnixSocketAddress, ffi::GUnixSocketAddressClass>) @extends SocketAddress, @implements SocketConnectable;
68
69    match fn {
70        type_ => || ffi::g_unix_socket_address_get_type(),
71    }
72}
73
74impl UnixSocketAddress {
75    pub const NONE: Option<&'static UnixSocketAddress> = None;
76
77    //#[doc(alias = "g_unix_socket_address_new_abstract")]
78    //pub fn new_abstract(path: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 10 }) -> UnixSocketAddress {
79    //    unsafe { TODO: call ffi:g_unix_socket_address_new_abstract() }
80    //}
81
82    //#[doc(alias = "g_unix_socket_address_new_with_type")]
83    //#[doc(alias = "new_with_type")]
84    //pub fn with_type(path: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 10 }, type_: UnixSocketAddressType) -> UnixSocketAddress {
85    //    unsafe { TODO: call ffi:g_unix_socket_address_new_with_type() }
86    //}
87
88    /// Checks if abstract UNIX domain socket names are supported.
89    ///
90    /// # Returns
91    ///
92    /// [`true`] if supported, [`false`] otherwise
93    #[doc(alias = "g_unix_socket_address_abstract_names_supported")]
94    pub fn abstract_names_supported() -> bool {
95        unsafe { from_glib(ffi::g_unix_socket_address_abstract_names_supported()) }
96    }
97}
98
99unsafe impl Send for UnixSocketAddress {}
100unsafe impl Sync for UnixSocketAddress {}
101
102mod sealed {
103    pub trait Sealed {}
104    impl<T: super::IsA<super::UnixSocketAddress>> Sealed for T {}
105}
106
107/// Trait containing all [`struct@UnixSocketAddress`] methods.
108///
109/// # Implementors
110///
111/// [`UnixSocketAddress`][struct@crate::UnixSocketAddress]
112pub trait UnixSocketAddressExt: IsA<UnixSocketAddress> + sealed::Sealed + 'static {
113    /// Gets @self's type.
114    ///
115    /// # Returns
116    ///
117    /// a #GUnixSocketAddressType
118    #[doc(alias = "g_unix_socket_address_get_address_type")]
119    #[doc(alias = "get_address_type")]
120    #[doc(alias = "address-type")]
121    fn address_type(&self) -> UnixSocketAddressType {
122        unsafe {
123            from_glib(ffi::g_unix_socket_address_get_address_type(
124                self.as_ref().to_glib_none().0,
125            ))
126        }
127    }
128
129    /// Tests if @self is abstract.
130    ///
131    /// # Deprecated
132    ///
133    /// Use g_unix_socket_address_get_address_type()
134    ///
135    /// # Returns
136    ///
137    /// [`true`] if the address is abstract, [`false`] otherwise
138    #[doc(alias = "g_unix_socket_address_get_is_abstract")]
139    #[doc(alias = "get_is_abstract")]
140    fn is_abstract(&self) -> bool {
141        unsafe {
142            from_glib(ffi::g_unix_socket_address_get_is_abstract(
143                self.as_ref().to_glib_none().0,
144            ))
145        }
146    }
147
148    /// Gets the length of @self's path.
149    ///
150    /// For details, see g_unix_socket_address_get_path().
151    ///
152    /// # Returns
153    ///
154    /// the length of the path
155    #[doc(alias = "g_unix_socket_address_get_path_len")]
156    #[doc(alias = "get_path_len")]
157    fn path_len(&self) -> usize {
158        unsafe { ffi::g_unix_socket_address_get_path_len(self.as_ref().to_glib_none().0) }
159    }
160
161    /// Unix socket path, as a byte array.
162    #[doc(alias = "path-as-array")]
163    fn path_as_array(&self) -> Option<glib::ByteArray> {
164        ObjectExt::property(self.as_ref(), "path-as-array")
165    }
166}
167
168impl<O: IsA<UnixSocketAddress>> UnixSocketAddressExt for O {}