gio/auto/
unix_fd_message.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, SocketControlMessage, UnixFDList};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// This [`SocketControlMessage`][crate::SocketControlMessage] contains a [`UnixFDList`][crate::UnixFDList].
10    /// It may be sent using [`SocketExtManual::send_message()`][crate::prelude::SocketExtManual::send_message()] and received using
11    /// [`SocketExtManual::receive_message()`][crate::prelude::SocketExtManual::receive_message()] over UNIX sockets (ie: sockets in the
12    /// `G_SOCKET_FAMILY_UNIX` family). The file descriptors are copied
13    /// between processes by the kernel.
14    ///
15    /// For an easier way to send and receive file descriptors over
16    /// stream-oriented UNIX sockets, see [`UnixConnectionExt::send_fd()`][crate::prelude::UnixConnectionExt::send_fd()] and
17    /// [`UnixConnectionExt::receive_fd()`][crate::prelude::UnixConnectionExt::receive_fd()].
18    ///
19    /// Note that `<gio/gunixfdmessage.h>` belongs to the UNIX-specific GIO
20    /// interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
21    /// file or the `GioUnix-2.0` GIR namespace when using it.
22    ///
23    /// ## Properties
24    ///
25    ///
26    /// #### `fd-list`
27    ///  The [`UnixFDList`][crate::UnixFDList] object to send with the message.
28    ///
29    /// Readable | Writeable | Construct Only
30    ///
31    /// # Implements
32    ///
33    /// [`UnixFDMessageExt`][trait@crate::prelude::UnixFDMessageExt], [`SocketControlMessageExt`][trait@crate::prelude::SocketControlMessageExt], [`trait@glib::ObjectExt`], [`UnixFDMessageExtManual`][trait@crate::prelude::UnixFDMessageExtManual], [`SocketControlMessageExtManual`][trait@crate::prelude::SocketControlMessageExtManual]
34    #[doc(alias = "GUnixFDMessage")]
35    pub struct UnixFDMessage(Object<ffi::GUnixFDMessage, ffi::GUnixFDMessageClass>) @extends SocketControlMessage;
36
37    match fn {
38        type_ => || ffi::g_unix_fd_message_get_type(),
39    }
40}
41
42impl UnixFDMessage {
43    pub const NONE: Option<&'static UnixFDMessage> = None;
44
45    /// Creates a new #GUnixFDMessage containing an empty file descriptor
46    /// list.
47    ///
48    /// # Returns
49    ///
50    /// a new #GUnixFDMessage
51    #[doc(alias = "g_unix_fd_message_new")]
52    pub fn new() -> UnixFDMessage {
53        unsafe { SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new()).unsafe_cast() }
54    }
55
56    /// Creates a new #GUnixFDMessage containing @list.
57    /// ## `fd_list`
58    /// a #GUnixFDList
59    ///
60    /// # Returns
61    ///
62    /// a new #GUnixFDMessage
63    #[doc(alias = "g_unix_fd_message_new_with_fd_list")]
64    #[doc(alias = "new_with_fd_list")]
65    pub fn with_fd_list(fd_list: &impl IsA<UnixFDList>) -> UnixFDMessage {
66        unsafe {
67            SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new_with_fd_list(
68                fd_list.as_ref().to_glib_none().0,
69            ))
70            .unsafe_cast()
71        }
72    }
73}
74
75impl Default for UnixFDMessage {
76    fn default() -> Self {
77        Self::new()
78    }
79}
80
81mod sealed {
82    pub trait Sealed {}
83    impl<T: super::IsA<super::UnixFDMessage>> Sealed for T {}
84}
85
86/// Trait containing all [`struct@UnixFDMessage`] methods.
87///
88/// # Implementors
89///
90/// [`UnixFDMessage`][struct@crate::UnixFDMessage]
91pub trait UnixFDMessageExt: IsA<UnixFDMessage> + sealed::Sealed + 'static {
92    /// Gets the #GUnixFDList contained in @self.  This function does not
93    /// return a reference to the caller, but the returned list is valid for
94    /// the lifetime of @self.
95    ///
96    /// # Returns
97    ///
98    /// the #GUnixFDList from @self
99    #[doc(alias = "g_unix_fd_message_get_fd_list")]
100    #[doc(alias = "get_fd_list")]
101    #[doc(alias = "fd-list")]
102    fn fd_list(&self) -> UnixFDList {
103        unsafe {
104            from_glib_none(ffi::g_unix_fd_message_get_fd_list(
105                self.as_ref().to_glib_none().0,
106            ))
107        }
108    }
109}
110
111impl<O: IsA<UnixFDMessage>> UnixFDMessageExt for O {}