gio/auto/
pollable_input_stream.rs1use gio_sys;
6use glib::object::IsA;
7use glib::translate::*;
8use std::fmt;
9use InputStream;
10
11glib_wrapper! {
12 pub struct PollableInputStream(Interface<gio_sys::GPollableInputStream>) @requires InputStream;
13
14 match fn {
15 get_type => || gio_sys::g_pollable_input_stream_get_type(),
16 }
17}
18
19pub const NONE_POLLABLE_INPUT_STREAM: Option<&PollableInputStream> = None;
20
21pub trait PollableInputStreamExt: 'static {
22 fn can_poll(&self) -> bool;
23
24 fn is_readable(&self) -> bool;
25}
26
27impl<O: IsA<PollableInputStream>> PollableInputStreamExt for O {
28 fn can_poll(&self) -> bool {
29 unsafe {
30 from_glib(gio_sys::g_pollable_input_stream_can_poll(
31 self.as_ref().to_glib_none().0,
32 ))
33 }
34 }
35
36 fn is_readable(&self) -> bool {
37 unsafe {
38 from_glib(gio_sys::g_pollable_input_stream_is_readable(
39 self.as_ref().to_glib_none().0,
40 ))
41 }
42 }
43}
44
45impl fmt::Display for PollableInputStream {
46 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
47 write!(f, "PollableInputStream")
48 }
49}