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 module gio.PollableOutputStreamIF;
26 
27 private import gio.Cancellable;
28 private import gio.c.functions;
29 public  import gio.c.types;
30 private import glib.ErrorG;
31 private import glib.GException;
32 private import glib.Source;
33 
34 
35 /**
36  * #GPollableOutputStream is implemented by #GOutputStreams that
37  * can be polled for readiness to write. This can be used when
38  * interfacing with a non-GIO API that expects
39  * UNIX-file-descriptor-style asynchronous I/O rather than GIO-style.
40  *
41  * Since: 2.28
42  */
43 public interface PollableOutputStreamIF{
44 	/** Get the main Gtk struct */
45 	public GPollableOutputStream* getPollableOutputStreamStruct(bool transferOwnership = false);
46 
47 	/** the main Gtk struct as a void* */
48 	protected void* getStruct();
49 
50 
51 	/** */
52 	public static GType getType()
53 	{
54 		return g_pollable_output_stream_get_type();
55 	}
56 
57 	/**
58 	 * Checks if @stream is actually pollable. Some classes may implement
59 	 * #GPollableOutputStream but have only certain instances of that
60 	 * class be pollable. If this method returns %FALSE, then the behavior
61 	 * of other #GPollableOutputStream methods is undefined.
62 	 *
63 	 * For any given stream, the value returned by this method is constant;
64 	 * a stream cannot switch from pollable to non-pollable or vice versa.
65 	 *
66 	 * Returns: %TRUE if @stream is pollable, %FALSE if not.
67 	 *
68 	 * Since: 2.28
69 	 */
70 	public bool canPoll();
71 
72 	/**
73 	 * Creates a #GSource that triggers when @stream can be written, or
74 	 * @cancellable is triggered or an error occurs. The callback on the
75 	 * source is of the #GPollableSourceFunc type.
76 	 *
77 	 * As with g_pollable_output_stream_is_writable(), it is possible that
78 	 * the stream may not actually be writable even after the source
79 	 * triggers, so you should use g_pollable_output_stream_write_nonblocking()
80 	 * rather than g_output_stream_write() from the callback.
81 	 *
82 	 * Params:
83 	 *     cancellable = a #GCancellable, or %NULL
84 	 *
85 	 * Returns: a new #GSource
86 	 *
87 	 * Since: 2.28
88 	 */
89 	public Source createSource(Cancellable cancellable);
90 
91 	/**
92 	 * Checks if @stream can be written.
93 	 *
94 	 * Note that some stream types may not be able to implement this 100%
95 	 * reliably, and it is possible that a call to g_output_stream_write()
96 	 * after this returns %TRUE would still block. To guarantee
97 	 * non-blocking behavior, you should always use
98 	 * g_pollable_output_stream_write_nonblocking(), which will return a
99 	 * %G_IO_ERROR_WOULD_BLOCK error rather than blocking.
100 	 *
101 	 * Returns: %TRUE if @stream is writable, %FALSE if not. If an error
102 	 *     has occurred on @stream, this will result in
103 	 *     g_pollable_output_stream_is_writable() returning %TRUE, and the
104 	 *     next attempt to write will return the error.
105 	 *
106 	 * Since: 2.28
107 	 */
108 	public bool isWritable();
109 
110 	/**
111 	 * Attempts to write up to @count bytes from @buffer to @stream, as
112 	 * with g_output_stream_write(). If @stream is not currently writable,
113 	 * this will immediately return %G_IO_ERROR_WOULD_BLOCK, and you can
114 	 * use g_pollable_output_stream_create_source() to create a #GSource
115 	 * that will be triggered when @stream is writable.
116 	 *
117 	 * Note that since this method never blocks, you cannot actually
118 	 * use @cancellable to cancel it. However, it will return an error
119 	 * if @cancellable has already been cancelled when you call, which
120 	 * may happen if you call this method after a source triggers due
121 	 * to having been cancelled.
122 	 *
123 	 * Also note that if %G_IO_ERROR_WOULD_BLOCK is returned some underlying
124 	 * transports like D/TLS require that you re-send the same @buffer and
125 	 * @count in the next write call.
126 	 *
127 	 * Params:
128 	 *     buffer = a buffer to write
129 	 *         data from
130 	 *     cancellable = a #GCancellable, or %NULL
131 	 *
132 	 * Returns: the number of bytes written, or -1 on error (including
133 	 *     %G_IO_ERROR_WOULD_BLOCK).
134 	 *
135 	 * Throws: GException on failure.
136 	 */
137 	public ptrdiff_t writeNonblocking(ubyte[] buffer, Cancellable cancellable);
138 
139 	/**
140 	 * Attempts to write the bytes contained in the @n_vectors @vectors to @stream,
141 	 * as with g_output_stream_writev(). If @stream is not currently writable,
142 	 * this will immediately return %@G_POLLABLE_RETURN_WOULD_BLOCK, and you can
143 	 * use g_pollable_output_stream_create_source() to create a #GSource
144 	 * that will be triggered when @stream is writable. @error will *not* be
145 	 * set in that case.
146 	 *
147 	 * Note that since this method never blocks, you cannot actually
148 	 * use @cancellable to cancel it. However, it will return an error
149 	 * if @cancellable has already been cancelled when you call, which
150 	 * may happen if you call this method after a source triggers due
151 	 * to having been cancelled.
152 	 *
153 	 * Also note that if %G_POLLABLE_RETURN_WOULD_BLOCK is returned some underlying
154 	 * transports like D/TLS require that you re-send the same @vectors and
155 	 * @n_vectors in the next write call.
156 	 *
157 	 * Params:
158 	 *     vectors = the buffer containing the #GOutputVectors to write.
159 	 *     bytesWritten = location to store the number of bytes that were
160 	 *         written to the stream
161 	 *     cancellable = a #GCancellable, or %NULL
162 	 *
163 	 * Returns: %@G_POLLABLE_RETURN_OK on success, %G_POLLABLE_RETURN_WOULD_BLOCK
164 	 *     if the stream is not currently writable (and @error is *not* set), or
165 	 *     %G_POLLABLE_RETURN_FAILED if there was an error in which case @error will
166 	 *     be set.
167 	 *
168 	 * Since: 2.60
169 	 *
170 	 * Throws: GException on failure.
171 	 */
172 	public GPollableReturn writevNonblocking(GOutputVector[] vectors, out size_t bytesWritten, Cancellable cancellable);
173 }