gio_unix/auto/
input_stream.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, FileDescriptorBased};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// `GUnixInputStream` implements [`gio::InputStream`][crate::gio::InputStream] for reading from a UNIX
10    /// file descriptor, including asynchronous operations. (If the file
11    /// descriptor refers to a socket or pipe, this will use `poll()` to do
12    /// asynchronous I/O. If it refers to a regular file, it will fall back
13    /// to doing asynchronous I/O in another thread.)
14    ///
15    /// Note that `<gio/gunixinputstream.h>` belongs to the UNIX-specific GIO
16    /// interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config
17    /// file or the `GioUnix-2.0` GIR namespace when using it.
18    ///
19    /// ## Properties
20    ///
21    ///
22    /// #### `close-fd`
23    ///  Whether to close the file descriptor when the stream is closed.
24    ///
25    /// Readable | Writeable
26    ///
27    ///
28    /// #### `fd`
29    ///  The file descriptor that the stream reads from.
30    ///
31    /// Readable | Writeable | Construct Only
32    ///
33    /// # Implements
34    ///
35    /// [`UnixInputStreamExt`][trait@crate::prelude::UnixInputStreamExt], [`trait@gio::prelude::InputStreamExt`], [`trait@gio::prelude::PollableInputStreamExt`], [`FileDescriptorBasedExt`][trait@crate::prelude::FileDescriptorBasedExt], [`UnixInputStreamExtManual`][trait@crate::prelude::UnixInputStreamExtManual], [`FileDescriptorBasedExtManual`][trait@crate::prelude::FileDescriptorBasedExtManual]
36    #[doc(alias = "GUnixInputStream")]
37    pub struct InputStream(Object<ffi::GUnixInputStream, ffi::GUnixInputStreamClass>) @extends gio::InputStream, @implements gio::PollableInputStream, FileDescriptorBased;
38
39    match fn {
40        type_ => || ffi::g_unix_input_stream_get_type(),
41    }
42}
43
44impl InputStream {
45    pub const NONE: Option<&'static InputStream> = None;
46}
47
48/// Trait containing all [`struct@InputStream`] methods.
49///
50/// # Implementors
51///
52/// [`InputStream`][struct@crate::InputStream]
53pub trait UnixInputStreamExt: IsA<InputStream> + 'static {
54    /// Returns whether the file descriptor of @self will be
55    /// closed when the stream is closed.
56    ///
57    /// # Returns
58    ///
59    /// [`true`] if the file descriptor is closed when done
60    #[doc(alias = "g_unix_input_stream_get_close_fd")]
61    #[doc(alias = "get_close_fd")]
62    #[doc(alias = "close-fd")]
63    fn closes_fd(&self) -> bool {
64        unsafe {
65            from_glib(ffi::g_unix_input_stream_get_close_fd(
66                self.as_ref().to_glib_none().0,
67            ))
68        }
69    }
70}
71
72impl<O: IsA<InputStream>> UnixInputStreamExt for O {}