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 public import gtkc.giotypes; 34 35 36 /** 37 * #GPollableOutputStream is implemented by #GOutputStreams that 38 * can be polled for readiness to write. This can be used when 39 * interfacing with a non-GIO API that expects 40 * UNIX-file-descriptor-style asynchronous I/O rather than GIO-style. 41 * 42 * Since: 2.28 43 */ 44 public interface PollableOutputStreamIF{ 45 /** Get the main Gtk struct */ 46 public GPollableOutputStream* getPollableOutputStreamStruct(bool transferOwnership = false); 47 48 /** the main Gtk struct as a void* */ 49 protected void* getStruct(); 50 51 52 /** */ 53 public static GType getType() 54 { 55 return g_pollable_output_stream_get_type(); 56 } 57 58 /** 59 * Checks if @stream is actually pollable. Some classes may implement 60 * #GPollableOutputStream but have only certain instances of that 61 * class be pollable. If this method returns %FALSE, then the behavior 62 * of other #GPollableOutputStream methods is undefined. 63 * 64 * For any given stream, the value returned by this method is constant; 65 * a stream cannot switch from pollable to non-pollable or vice versa. 66 * 67 * Returns: %TRUE if @stream is pollable, %FALSE if not. 68 * 69 * Since: 2.28 70 */ 71 public bool canPoll(); 72 73 /** 74 * Creates a #GSource that triggers when @stream can be written, or 75 * @cancellable is triggered or an error occurs. The callback on the 76 * source is of the #GPollableSourceFunc type. 77 * 78 * As with g_pollable_output_stream_is_writable(), it is possible that 79 * the stream may not actually be writable even after the source 80 * triggers, so you should use g_pollable_output_stream_write_nonblocking() 81 * rather than g_output_stream_write() from the callback. 82 * 83 * Params: 84 * cancellable = a #GCancellable, or %NULL 85 * 86 * Returns: a new #GSource 87 * 88 * Since: 2.28 89 */ 90 public Source createSource(Cancellable cancellable); 91 92 /** 93 * Checks if @stream can be written. 94 * 95 * Note that some stream types may not be able to implement this 100% 96 * reliably, and it is possible that a call to g_output_stream_write() 97 * after this returns %TRUE would still block. To guarantee 98 * non-blocking behavior, you should always use 99 * g_pollable_output_stream_write_nonblocking(), which will return a 100 * %G_IO_ERROR_WOULD_BLOCK error rather than blocking. 101 * 102 * Returns: %TRUE if @stream is writable, %FALSE if not. If an error 103 * has occurred on @stream, this will result in 104 * g_pollable_output_stream_is_writable() returning %TRUE, and the 105 * next attempt to write will return the error. 106 * 107 * Since: 2.28 108 */ 109 public bool isWritable(); 110 111 /** 112 * Attempts to write up to @count bytes from @buffer to @stream, as 113 * with g_output_stream_write(). If @stream is not currently writable, 114 * this will immediately return %G_IO_ERROR_WOULD_BLOCK, and you can 115 * use g_pollable_output_stream_create_source() to create a #GSource 116 * that will be triggered when @stream is writable. 117 * 118 * Note that since this method never blocks, you cannot actually 119 * use @cancellable to cancel it. However, it will return an error 120 * if @cancellable has already been cancelled when you call, which 121 * may happen if you call this method after a source triggers due 122 * to having been cancelled. 123 * 124 * Also note that if %G_IO_ERROR_WOULD_BLOCK is returned some underlying 125 * transports like D/TLS require that you send the same @buffer and @count. 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 }