1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GPollableInputStream.html
27  * outPack = gio
28  * outFile = PollableInputStreamIF
29  * strct   = GPollableInputStream
30  * realStrct=
31  * ctorStrct=
32  * clss    = PollableInputStreamT
33  * interf  = PollableInputStreamIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_pollable_input_stream_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- gobject.ObjectG
47  * 	- glib.ErrorG
48  * 	- glib.GException
49  * 	- glib.Source
50  * 	- gio.Cancellable
51  * structWrap:
52  * 	- GCancellable* -> Cancellable
53  * 	- GObject* -> ObjectG
54  * 	- GSource* -> Source
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gio.PollableInputStreamIF;
61 
62 public  import gtkc.giotypes;
63 
64 private import gtkc.gio;
65 private import glib.ConstructionException;
66 private import gobject.ObjectG;
67 
68 
69 private import gobject.ObjectG;
70 private import glib.ErrorG;
71 private import glib.GException;
72 private import glib.Source;
73 private import gio.Cancellable;
74 
75 
76 
77 
78 /**
79  * Description
80  * GPollableInputStream is implemented by GInputStreams that
81  * can be polled for readiness to read. This can be used when
82  * interfacing with a non-GIO API that expects
83  * UNIX-file-descriptor-style asynchronous I/O rather than GIO-style.
84  */
85 public interface PollableInputStreamIF
86 {
87 	
88 	
89 	public GPollableInputStream* getPollableInputStreamTStruct();
90 	
91 	/** the main Gtk struct as a void* */
92 	protected void* getStruct();
93 	
94 	
95 	/**
96 	 */
97 	
98 	/**
99 	 * Checks if stream is actually pollable. Some classes may implement
100 	 * GPollableInputStream but have only certain instances of that class
101 	 * be pollable. If this method returns FALSE, then the behavior of
102 	 * other GPollableInputStream methods is undefined.
103 	 * For any given stream, the value returned by this method is constant;
104 	 * a stream cannot switch from pollable to non-pollable or vice versa.
105 	 * Since 2.28
106 	 * Returns: TRUE if stream is pollable, FALSE if not.
107 	 */
108 	public int canPoll();
109 	
110 	/**
111 	 * Checks if stream can be read.
112 	 * Note that some stream types may not be able to implement this 100%
113 	 * reliably, and it is possible that a call to g_input_stream_read()
114 	 * after this returns TRUE would still block. To guarantee
115 	 * non-blocking behavior, you should always use
116 	 * g_pollable_input_stream_read_nonblocking(), which will return a
117 	 * G_IO_ERROR_WOULD_BLOCK error rather than blocking.
118 	 * Since 2.28
119 	 * Returns: TRUE if stream is readable, FALSE if not. If an error has occurred on stream, this will result in g_pollable_input_stream_is_readable() returning TRUE, and the next attempt to read will return the error.
120 	 */
121 	public int isReadable();
122 	
123 	/**
124 	 * Creates a GSource that triggers when stream can be read, or
125 	 * cancellable is triggered or an error occurs. The callback on the
126 	 * source is of the GPollableSourceFunc type.
127 	 * As with g_pollable_input_stream_is_readable(), it is possible that
128 	 * the stream may not actually be readable even after the source
129 	 * triggers, so you should use g_pollable_input_stream_read_nonblocking()
130 	 * rather than g_input_stream_read() from the callback.
131 	 * Since 2.28
132 	 * Params:
133 	 * cancellable = a GCancellable, or NULL. [allow-none]
134 	 * Returns: a new GSource. [transfer full]
135 	 */
136 	public Source createSource(Cancellable cancellable);
137 	
138 	/**
139 	 * Attempts to read up to size bytes from stream into buffer, as
140 	 * with g_input_stream_read(). If stream is not currently readable,
141 	 * this will immediately return G_IO_ERROR_WOULD_BLOCK, and you can
142 	 * use g_pollable_input_stream_create_source() to create a GSource
143 	 * that will be triggered when stream is readable.
144 	 * Note that since this method never blocks, you cannot actually
145 	 * use cancellable to cancel it. However, it will return an error
146 	 * if cancellable has already been cancelled when you call, which
147 	 * may happen if you call this method after a source triggers due
148 	 * to having been cancelled.
149 	 * Virtual: read_nonblocking
150 	 * Params:
151 	 * buffer = a buffer to read data into (which should be at least size
152 	 * bytes long).
153 	 * size = the number of bytes you want to read
154 	 * cancellable = a GCancellable, or NULL. [allow-none]
155 	 * Returns: the number of bytes read, or -1 on error (including G_IO_ERROR_WOULD_BLOCK).
156 	 * Throws: GException on failure.
157 	 */
158 	public gssize readNonblocking(void[] buffer, Cancellable cancellable);
159 	
160 	/**
161 	 * Utility method for GPollableInputStream and GPollableOutputStream
162 	 * implementations. Creates a new GSource that expects a callback of
163 	 * type GPollableSourceFunc. The new source does not actually do
164 	 * anything on its own; use g_source_add_child_source() to add other
165 	 * sources to it to cause it to trigger.
166 	 * Since 2.28
167 	 * Params:
168 	 * pollableStream = the stream associated with the new source
169 	 * Returns: the new GSource. [transfer full]
170 	 */
171 	public static Source gPollableSourceNew(ObjectG pollableStream);
172 }