gio/auto/unix_fd_list.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 /// A `GUnixFDList` contains a list of file descriptors. It owns the file
10 /// descriptors that it contains, closing them when finalized.
11 ///
12 /// It may be wrapped in a
13 /// [`GUnixFDMessage`](../gio-unix/class.UnixFDMessage.html) and sent over a
14 /// [`Socket`][crate::Socket] in the `G_SOCKET_FAMILY_UNIX` family by using
15 /// [`SocketExtManual::send_message()`][crate::prelude::SocketExtManual::send_message()] and received using
16 /// [`SocketExtManual::receive_message()`][crate::prelude::SocketExtManual::receive_message()].
17 ///
18 /// Before 2.74, `<gio/gunixfdlist.h>` belonged to the UNIX-specific GIO
19 /// interfaces, thus you had to use the `gio-unix-2.0.pc` pkg-config file when
20 /// using it.
21 ///
22 /// Since 2.74, the API is available for Windows.
23 ///
24 /// # Implements
25 ///
26 /// [`UnixFDListExt`][trait@crate::prelude::UnixFDListExt], [`trait@glib::ObjectExt`], [`UnixFDListExtManual`][trait@crate::prelude::UnixFDListExtManual]
27 #[doc(alias = "GUnixFDList")]
28 pub struct UnixFDList(Object<ffi::GUnixFDList, ffi::GUnixFDListClass>);
29
30 match fn {
31 type_ => || ffi::g_unix_fd_list_get_type(),
32 }
33}
34
35impl UnixFDList {
36 pub const NONE: Option<&'static UnixFDList> = None;
37
38 /// Creates a new #GUnixFDList containing no file descriptors.
39 ///
40 /// # Returns
41 ///
42 /// a new #GUnixFDList
43 #[doc(alias = "g_unix_fd_list_new")]
44 pub fn new() -> UnixFDList {
45 unsafe { from_glib_full(ffi::g_unix_fd_list_new()) }
46 }
47}
48
49impl Default for UnixFDList {
50 fn default() -> Self {
51 Self::new()
52 }
53}
54
55/// Trait containing all [`struct@UnixFDList`] methods.
56///
57/// # Implementors
58///
59/// [`UnixFDList`][struct@crate::UnixFDList]
60pub trait UnixFDListExt: IsA<UnixFDList> + 'static {
61 /// Gets the length of @self (ie: the number of file descriptors
62 /// contained within).
63 ///
64 /// # Returns
65 ///
66 /// the length of @self
67 #[doc(alias = "g_unix_fd_list_get_length")]
68 #[doc(alias = "get_length")]
69 fn length(&self) -> i32 {
70 unsafe { ffi::g_unix_fd_list_get_length(self.as_ref().to_glib_none().0) }
71 }
72}
73
74impl<O: IsA<UnixFDList>> UnixFDListExt for O {}