gio_unix/auto/
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;
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// This [`gio::SocketControlMessage`][crate::gio::SocketControlMessage] contains a [`gio::UnixFDList`][crate::gio::UnixFDList].
10    /// It may be sent using `Gio::Socket::send_message()` and received using
11    /// `Gio::Socket::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 `Gio::UnixConnection::send_fd()` and
17    /// `Gio::UnixConnection::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 [`gio::UnixFDList`][crate::gio::UnixFDList] object to send with the message.
28    ///
29    /// Readable | Writeable | Construct Only
30    ///
31    /// # Implements
32    ///
33    /// [`FDMessageExt`][trait@crate::prelude::FDMessageExt], [`trait@gio::prelude::SocketControlMessageExt`], [`FDMessageExtManual`][trait@crate::prelude::FDMessageExtManual]
34    #[doc(alias = "GUnixFDMessage")]
35    pub struct FDMessage(Object<ffi::GUnixFDMessage, ffi::GUnixFDMessageClass>) @extends gio::SocketControlMessage;
36
37    match fn {
38        type_ => || ffi::g_unix_fd_message_get_type(),
39    }
40}
41
42impl FDMessage {
43    pub const NONE: Option<&'static FDMessage> = 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() -> FDMessage {
53        unsafe {
54            gio::SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new()).unsafe_cast()
55        }
56    }
57
58    /// Creates a new #GUnixFDMessage containing @list.
59    /// ## `fd_list`
60    /// a #GUnixFDList
61    ///
62    /// # Returns
63    ///
64    /// a new #GUnixFDMessage
65    #[doc(alias = "g_unix_fd_message_new_with_fd_list")]
66    #[doc(alias = "new_with_fd_list")]
67    pub fn with_fd_list(fd_list: &impl IsA<gio::UnixFDList>) -> FDMessage {
68        unsafe {
69            gio::SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new_with_fd_list(
70                fd_list.as_ref().to_glib_none().0,
71            ))
72            .unsafe_cast()
73        }
74    }
75}
76
77impl Default for FDMessage {
78    fn default() -> Self {
79        Self::new()
80    }
81}
82
83/// Trait containing all [`struct@FDMessage`] methods.
84///
85/// # Implementors
86///
87/// [`FDMessage`][struct@crate::FDMessage]
88pub trait FDMessageExt: IsA<FDMessage> + 'static {
89    /// Gets the #GUnixFDList contained in @self.  This function does not
90    /// return a reference to the caller, but the returned list is valid for
91    /// the lifetime of @self.
92    ///
93    /// # Returns
94    ///
95    /// the #GUnixFDList from @self
96    #[doc(alias = "g_unix_fd_message_get_fd_list")]
97    #[doc(alias = "get_fd_list")]
98    #[doc(alias = "fd-list")]
99    fn fd_list(&self) -> gio::UnixFDList {
100        unsafe {
101            from_glib_none(ffi::g_unix_fd_message_get_fd_list(
102                self.as_ref().to_glib_none().0,
103            ))
104        }
105    }
106}
107
108impl<O: IsA<FDMessage>> FDMessageExt for O {}