gio/auto/
unix_fd_message.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi, SocketControlMessage, UnixFDList};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// This [`SocketControlMessage`][crate::SocketControlMessage] contains a [`UnixFDList`][crate::UnixFDList].
    /// It may be sent using [`SocketExtManual::send_message()`][crate::prelude::SocketExtManual::send_message()] and received using
    /// [`SocketExtManual::receive_message()`][crate::prelude::SocketExtManual::receive_message()] over UNIX sockets (ie: sockets in the
    /// `G_SOCKET_FAMILY_UNIX` family). The file descriptors are copied
    /// between processes by the kernel.
    ///
    /// For an easier way to send and receive file descriptors over
    /// stream-oriented UNIX sockets, see `Gio::UnixConnection::send_fd()` and
    /// `Gio::UnixConnection::receive_fd()`.
    ///
    /// Note that `<gio/gunixfdmessage.h>` belongs to the UNIX-specific GIO
    /// interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
    /// file or the `GioUnix-2.0` GIR namespace when using it.
    ///
    /// ## Properties
    ///
    ///
    /// #### `fd-list`
    ///  The [`UnixFDList`][crate::UnixFDList] object to send with the message.
    ///
    /// Readable | Writeable | Construct Only
    ///
    /// # Implements
    ///
    /// [`UnixFDMessageExt`][trait@crate::prelude::UnixFDMessageExt], [`SocketControlMessageExt`][trait@crate::prelude::SocketControlMessageExt], [`trait@glib::ObjectExt`], [`UnixFDMessageExtManual`][trait@crate::prelude::UnixFDMessageExtManual], [`SocketControlMessageExtManual`][trait@crate::prelude::SocketControlMessageExtManual]
    #[doc(alias = "GUnixFDMessage")]
    pub struct UnixFDMessage(Object<ffi::GUnixFDMessage, ffi::GUnixFDMessageClass>) @extends SocketControlMessage;

    match fn {
        type_ => || ffi::g_unix_fd_message_get_type(),
    }
}

impl UnixFDMessage {
    pub const NONE: Option<&'static UnixFDMessage> = None;

    /// Creates a new #GUnixFDMessage containing an empty file descriptor
    /// list.
    ///
    /// # Returns
    ///
    /// a new #GUnixFDMessage
    #[doc(alias = "g_unix_fd_message_new")]
    pub fn new() -> UnixFDMessage {
        unsafe { SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new()).unsafe_cast() }
    }

    /// Creates a new #GUnixFDMessage containing @list.
    /// ## `fd_list`
    /// a #GUnixFDList
    ///
    /// # Returns
    ///
    /// a new #GUnixFDMessage
    #[doc(alias = "g_unix_fd_message_new_with_fd_list")]
    #[doc(alias = "new_with_fd_list")]
    pub fn with_fd_list(fd_list: &impl IsA<UnixFDList>) -> UnixFDMessage {
        unsafe {
            SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new_with_fd_list(
                fd_list.as_ref().to_glib_none().0,
            ))
            .unsafe_cast()
        }
    }
}

impl Default for UnixFDMessage {
    fn default() -> Self {
        Self::new()
    }
}

/// Trait containing all [`struct@UnixFDMessage`] methods.
///
/// # Implementors
///
/// [`UnixFDMessage`][struct@crate::UnixFDMessage]
pub trait UnixFDMessageExt: IsA<UnixFDMessage> + 'static {
    /// Gets the #GUnixFDList contained in @self.  This function does not
    /// return a reference to the caller, but the returned list is valid for
    /// the lifetime of @self.
    ///
    /// # Returns
    ///
    /// the #GUnixFDList from @self
    #[doc(alias = "g_unix_fd_message_get_fd_list")]
    #[doc(alias = "get_fd_list")]
    #[doc(alias = "fd-list")]
    fn fd_list(&self) -> UnixFDList {
        unsafe {
            from_glib_none(ffi::g_unix_fd_message_get_fd_list(
                self.as_ref().to_glib_none().0,
            ))
        }
    }
}

impl<O: IsA<UnixFDMessage>> UnixFDMessageExt for O {}