Skip to main content

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    /// ` belongs to the UNIX-specific GIO
10    /// interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
11    /// file or the `GioUnix-2.0` GIR namespace when using it.
12    ///
13    /// ## Properties
14    ///
15    ///
16    /// #### `fd-list`
17    ///  The [`gio::UnixFDList`][crate::gio::UnixFDList] object to send with the message.
18    ///
19    /// Readable | Writable | Construct Only
20    ///
21    /// # Implements
22    ///
23    /// [`FDMessageExt`][trait@crate::prelude::FDMessageExt], [`trait@gio::prelude::SocketControlMessageExt`], [`FDMessageExtManual`][trait@crate::prelude::FDMessageExtManual]
24    #[doc(alias = "GUnixFDMessage")]
25    pub struct FDMessage(Object<ffi::GUnixFDMessage, ffi::GUnixFDMessageClass>) @extends gio::SocketControlMessage;
26
27    match fn {
28        type_ => || ffi::g_unix_fd_message_get_type(),
29    }
30}
31
32impl FDMessage {
33    pub const NONE: Option<&'static FDMessage> = None;
34
35    /// Creates a new #GUnixFDMessage containing an empty file descriptor
36    /// list.
37    ///
38    /// # Returns
39    ///
40    /// a new #GUnixFDMessage
41    #[doc(alias = "g_unix_fd_message_new")]
42    pub fn new() -> FDMessage {
43        unsafe {
44            gio::SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new()).unsafe_cast()
45        }
46    }
47
48    /// Creates a new #GUnixFDMessage containing @list.
49    /// ## `fd_list`
50    /// a #GUnixFDList
51    ///
52    /// # Returns
53    ///
54    /// a new #GUnixFDMessage
55    #[doc(alias = "g_unix_fd_message_new_with_fd_list")]
56    #[doc(alias = "new_with_fd_list")]
57    pub fn with_fd_list(fd_list: &impl IsA<gio::UnixFDList>) -> FDMessage {
58        unsafe {
59            gio::SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new_with_fd_list(
60                fd_list.as_ref().to_glib_none().0,
61            ))
62            .unsafe_cast()
63        }
64    }
65}
66
67impl Default for FDMessage {
68    fn default() -> Self {
69        Self::new()
70    }
71}
72
73/// Trait containing all [`struct@FDMessage`] methods.
74///
75/// # Implementors
76///
77/// [`FDMessage`][struct@crate::FDMessage]
78pub trait FDMessageExt: IsA<FDMessage> + 'static {
79    /// Gets the #GUnixFDList contained in @self.  This function does not
80    /// return a reference to the caller, but the returned list is valid for
81    /// the lifetime of @self.
82    ///
83    /// # Returns
84    ///
85    /// the #GUnixFDList from @self
86    #[doc(alias = "g_unix_fd_message_get_fd_list")]
87    #[doc(alias = "get_fd_list")]
88    #[doc(alias = "fd-list")]
89    fn fd_list(&self) -> gio::UnixFDList {
90        unsafe {
91            from_glib_none(ffi::g_unix_fd_message_get_fd_list(
92                self.as_ref().to_glib_none().0,
93            ))
94        }
95    }
96}
97
98impl<O: IsA<FDMessage>> FDMessageExt for O {}