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 glib.ErrorG; 29 private import glib.GException; 30 private import glib.Source; 31 private import gtkc.gio; 32 public import gtkc.giotypes; 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(); 46 47 /** the main Gtk struct as a void* */ 48 protected void* getStruct(); 49 50 51 /** 52 * Checks if @stream is actually pollable. Some classes may implement 53 * #GPollableOutputStream but have only certain instances of that 54 * class be pollable. If this method returns %FALSE, then the behavior 55 * of other #GPollableOutputStream methods is undefined. 56 * 57 * For any given stream, the value returned by this method is constant; 58 * a stream cannot switch from pollable to non-pollable or vice versa. 59 * 60 * Return: %TRUE if @stream is pollable, %FALSE if not. 61 * 62 * Since: 2.28 63 */ 64 public bool canPoll(); 65 66 /** 67 * Creates a #GSource that triggers when @stream can be written, or 68 * @cancellable is triggered or an error occurs. The callback on the 69 * source is of the #GPollableSourceFunc type. 70 * 71 * As with g_pollable_output_stream_is_writable(), it is possible that 72 * the stream may not actually be writable even after the source 73 * triggers, so you should use g_pollable_output_stream_write_nonblocking() 74 * rather than g_output_stream_write() from the callback. 75 * 76 * Params: 77 * cancellable = a #GCancellable, or %NULL 78 * 79 * Return: a new #GSource 80 * 81 * Since: 2.28 82 */ 83 public Source createSource(Cancellable cancellable); 84 85 /** 86 * Checks if @stream can be written. 87 * 88 * Note that some stream types may not be able to implement this 100% 89 * reliably, and it is possible that a call to g_output_stream_write() 90 * after this returns %TRUE would still block. To guarantee 91 * non-blocking behavior, you should always use 92 * g_pollable_output_stream_write_nonblocking(), which will return a 93 * %G_IO_ERROR_WOULD_BLOCK error rather than blocking. 94 * 95 * Return: %TRUE if @stream is writable, %FALSE if not. If an error 96 * has occurred on @stream, this will result in 97 * g_pollable_output_stream_is_writable() returning %TRUE, and the 98 * next attempt to write will return the error. 99 * 100 * Since: 2.28 101 */ 102 public bool isWritable(); 103 104 /** 105 * Attempts to write up to @count bytes from @buffer to @stream, as 106 * with g_output_stream_write(). If @stream is not currently writable, 107 * this will immediately return %G_IO_ERROR_WOULD_BLOCK, and you can 108 * use g_pollable_output_stream_create_source() to create a #GSource 109 * that will be triggered when @stream is writable. 110 * 111 * Note that since this method never blocks, you cannot actually 112 * use @cancellable to cancel it. However, it will return an error 113 * if @cancellable has already been cancelled when you call, which 114 * may happen if you call this method after a source triggers due 115 * to having been cancelled. 116 * 117 * Params: 118 * buffer = a buffer to write 119 * data from 120 * count = the number of bytes you want to write 121 * cancellable = a #GCancellable, or %NULL 122 * 123 * Return: the number of bytes written, or -1 on error (including 124 * %G_IO_ERROR_WOULD_BLOCK). 125 * 126 * Throws: GException on failure. 127 */ 128 public ptrdiff_t writeNonblocking(ubyte[] buffer, Cancellable cancellable); 129 }