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  = GOutputStream.html
27  * outPack = gio
28  * outFile = OutputStream
29  * strct   = GOutputStream
30  * realStrct=
31  * ctorStrct=
32  * clss    = OutputStream
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = GObject
38  * implements:
39  * prefixes:
40  * 	- g_output_stream_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.ErrorG
47  * 	- glib.GException
48  * 	- glib.Bytes
49  * 	- gio.AsyncResultIF
50  * 	- gio.Cancellable
51  * 	- gio.InputStream
52  * structWrap:
53  * 	- GAsyncResult* -> AsyncResultIF
54  * 	- GBytes* -> Bytes
55  * 	- GCancellable* -> Cancellable
56  * 	- GInputStream* -> InputStream
57  * module aliases:
58  * local aliases:
59  * overrides:
60  */
61 
62 module gio.OutputStream;
63 
64 public  import gtkc.giotypes;
65 
66 private import gtkc.gio;
67 private import glib.ConstructionException;
68 private import gobject.ObjectG;
69 
70 private import glib.ErrorG;
71 private import glib.GException;
72 private import glib.Bytes;
73 private import gio.AsyncResultIF;
74 private import gio.Cancellable;
75 private import gio.InputStream;
76 
77 
78 private import gobject.ObjectG;
79 
80 /**
81  * GOutputStream has functions to write to a stream (g_output_stream_write()),
82  * to close a stream (g_output_stream_close()) and to flush pending writes
83  * (g_output_stream_flush()).
84  *
85  * To copy the content of an input stream to an output stream without
86  * manually handling the reads and writes, use g_output_stream_splice().
87  *
88  * All of these functions have async variants too.
89  */
90 public class OutputStream : ObjectG
91 {
92 	
93 	/** the main Gtk struct */
94 	protected GOutputStream* gOutputStream;
95 	
96 	
97 	/** Get the main Gtk struct */
98 	public GOutputStream* getOutputStreamStruct()
99 	{
100 		return gOutputStream;
101 	}
102 	
103 	
104 	/** the main Gtk struct as a void* */
105 	protected override void* getStruct()
106 	{
107 		return cast(void*)gOutputStream;
108 	}
109 	
110 	/**
111 	 * Sets our main struct and passes it to the parent class
112 	 */
113 	public this (GOutputStream* gOutputStream)
114 	{
115 		super(cast(GObject*)gOutputStream);
116 		this.gOutputStream = gOutputStream;
117 	}
118 	
119 	protected override void setStruct(GObject* obj)
120 	{
121 		super.setStruct(obj);
122 		gOutputStream = cast(GOutputStream*)obj;
123 	}
124 	
125 	/**
126 	 */
127 	
128 	/**
129 	 * Tries to write count bytes from buffer into the stream. Will block
130 	 * during the operation.
131 	 * If count is 0, returns 0 and does nothing. A value of count
132 	 * larger than G_MAXSSIZE will cause a G_IO_ERROR_INVALID_ARGUMENT error.
133 	 * On success, the number of bytes written to the stream is returned.
134 	 * It is not an error if this is not the same as the requested size, as it
135 	 * can happen e.g. on a partial I/O error, or if there is not enough
136 	 * storage in the stream. All writes block until at least one byte
137 	 * is written or an error occurs; 0 is never returned (unless
138 	 * count is 0).
139 	 * If cancellable is not NULL, then the operation can be cancelled by
140 	 * triggering the cancellable object from another thread. If the operation
141 	 * was cancelled, the error G_IO_ERROR_CANCELLED will be returned. If an
142 	 * operation was partially finished when the operation was cancelled the
143 	 * partial result will be returned, without an error.
144 	 * On error -1 is returned and error is set accordingly.
145 	 * Virtual: write_fn
146 	 * Params:
147 	 * buffer = the buffer containing the data to write. [array length=count][element-type guint8]
148 	 * count = the number of bytes to write
149 	 * cancellable = optional cancellable object. [allow-none]
150 	 * Returns: Number of bytes written, or -1 on error
151 	 * Throws: GException on failure.
152 	 */
153 	public gssize write(void* buffer, gsize count, Cancellable cancellable)
154 	{
155 		// gssize g_output_stream_write (GOutputStream *stream,  const void *buffer,  gsize count,  GCancellable *cancellable,  GError **error);
156 		GError* err = null;
157 		
158 		auto p = g_output_stream_write(gOutputStream, buffer, count, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
159 		
160 		if (err !is null)
161 		{
162 			throw new GException( new ErrorG(err) );
163 		}
164 		
165 		return p;
166 	}
167 	
168 	/**
169 	 * Tries to write count bytes from buffer into the stream. Will block
170 	 * during the operation.
171 	 * This function is similar to g_output_stream_write(), except it tries to
172 	 * write as many bytes as requested, only stopping on an error.
173 	 * On a successful write of count bytes, TRUE is returned, and bytes_written
174 	 * is set to count.
175 	 * If there is an error during the operation FALSE is returned and error
176 	 * is set to indicate the error status, bytes_written is updated to contain
177 	 * the number of bytes written into the stream before the error occurred.
178 	 * Params:
179 	 * buffer = the buffer containing the data to write. [array length=count][element-type guint8]
180 	 * count = the number of bytes to write
181 	 * bytesWritten = location to store the number of bytes that was
182 	 * written to the stream. [out]
183 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
184 	 * Returns: TRUE on success, FALSE if there was an error
185 	 * Throws: GException on failure.
186 	 */
187 	public int writeAll(void* buffer, gsize count, gsize* bytesWritten, Cancellable cancellable)
188 	{
189 		// gboolean g_output_stream_write_all (GOutputStream *stream,  const void *buffer,  gsize count,  gsize *bytes_written,  GCancellable *cancellable,  GError **error);
190 		GError* err = null;
191 		
192 		auto p = g_output_stream_write_all(gOutputStream, buffer, count, bytesWritten, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
193 		
194 		if (err !is null)
195 		{
196 			throw new GException( new ErrorG(err) );
197 		}
198 		
199 		return p;
200 	}
201 	
202 	/**
203 	 * Splices an input stream into an output stream.
204 	 * Params:
205 	 * source = a GInputStream.
206 	 * flags = a set of GOutputStreamSpliceFlags.
207 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
208 	 * Returns: a gssize containing the size of the data spliced, or -1 if an error occurred. Note that if the number of bytes spliced is greater than G_MAXSSIZE, then that will be returned, and there is no way to determine the actual number of bytes spliced.
209 	 * Throws: GException on failure.
210 	 */
211 	public gssize splice(InputStream source, GOutputStreamSpliceFlags flags, Cancellable cancellable)
212 	{
213 		// gssize g_output_stream_splice (GOutputStream *stream,  GInputStream *source,  GOutputStreamSpliceFlags flags,  GCancellable *cancellable,  GError **error);
214 		GError* err = null;
215 		
216 		auto p = g_output_stream_splice(gOutputStream, (source is null) ? null : source.getInputStreamStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
217 		
218 		if (err !is null)
219 		{
220 			throw new GException( new ErrorG(err) );
221 		}
222 		
223 		return p;
224 	}
225 	
226 	/**
227 	 * Forces a write of all user-space buffered data for the given
228 	 * stream. Will block during the operation. Closing the stream will
229 	 * implicitly cause a flush.
230 	 * This function is optional for inherited classes.
231 	 * If cancellable is not NULL, then the operation can be cancelled by
232 	 * triggering the cancellable object from another thread. If the operation
233 	 * was cancelled, the error G_IO_ERROR_CANCELLED will be returned.
234 	 * Params:
235 	 * cancellable = optional cancellable object. [allow-none]
236 	 * Returns: TRUE on success, FALSE on error
237 	 * Throws: GException on failure.
238 	 */
239 	public int flush(Cancellable cancellable)
240 	{
241 		// gboolean g_output_stream_flush (GOutputStream *stream,  GCancellable *cancellable,  GError **error);
242 		GError* err = null;
243 		
244 		auto p = g_output_stream_flush(gOutputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
245 		
246 		if (err !is null)
247 		{
248 			throw new GException( new ErrorG(err) );
249 		}
250 		
251 		return p;
252 	}
253 	
254 	/**
255 	 * Closes the stream, releasing resources related to it.
256 	 * Once the stream is closed, all other operations will return G_IO_ERROR_CLOSED.
257 	 * Closing a stream multiple times will not return an error.
258 	 * Closing a stream will automatically flush any outstanding buffers in the
259 	 * stream.
260 	 * Streams will be automatically closed when the last reference
261 	 * is dropped, but you might want to call this function to make sure
262 	 * resources are released as early as possible.
263 	 * Some streams might keep the backing store of the stream (e.g. a file descriptor)
264 	 * open after the stream is closed. See the documentation for the individual
265 	 * stream for details.
266 	 * On failure the first error that happened will be reported, but the close
267 	 * operation will finish as much as possible. A stream that failed to
268 	 * close will still return G_IO_ERROR_CLOSED for all operations. Still, it
269 	 * is important to check and report the error to the user, otherwise
270 	 * there might be a loss of data as all data might not be written.
271 	 * If cancellable is not NULL, then the operation can be cancelled by
272 	 * triggering the cancellable object from another thread. If the operation
273 	 * was cancelled, the error G_IO_ERROR_CANCELLED will be returned.
274 	 * Cancelling a close will still leave the stream closed, but there some streams
275 	 * can use a faster close that doesn't block to e.g. check errors. On
276 	 * cancellation (as with any error) there is no guarantee that all written
277 	 * data will reach the target.
278 	 * Params:
279 	 * cancellable = optional cancellable object. [allow-none]
280 	 * Returns: TRUE on success, FALSE on failure
281 	 * Throws: GException on failure.
282 	 */
283 	public int close(Cancellable cancellable)
284 	{
285 		// gboolean g_output_stream_close (GOutputStream *stream,  GCancellable *cancellable,  GError **error);
286 		GError* err = null;
287 		
288 		auto p = g_output_stream_close(gOutputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
289 		
290 		if (err !is null)
291 		{
292 			throw new GException( new ErrorG(err) );
293 		}
294 		
295 		return p;
296 	}
297 	
298 	/**
299 	 * Request an asynchronous write of count bytes from buffer into
300 	 * the stream. When the operation is finished callback will be called.
301 	 * You can then call g_output_stream_write_finish() to get the result of the
302 	 * operation.
303 	 * During an async request no other sync and async calls are allowed,
304 	 * and will result in G_IO_ERROR_PENDING errors.
305 	 * A value of count larger than G_MAXSSIZE will cause a
306 	 * G_IO_ERROR_INVALID_ARGUMENT error.
307 	 * On success, the number of bytes written will be passed to the
308 	 * callback. It is not an error if this is not the same as the
309 	 * requested size, as it can happen e.g. on a partial I/O error,
310 	 * but generally we try to write as many bytes as requested.
311 	 * You are guaranteed that this method will never fail with
312 	 * G_IO_ERROR_WOULD_BLOCK - if stream can't accept more data, the
313 	 * method will just wait until this changes.
314 	 * Any outstanding I/O request with higher priority (lower numerical
315 	 * value) will be executed before an outstanding request with lower
316 	 * priority. Default priority is G_PRIORITY_DEFAULT.
317 	 * The asyncronous methods have a default fallback that uses threads
318 	 * to implement asynchronicity, so they are optional for inheriting
319 	 * classes. However, if you override one you must override all.
320 	 * For the synchronous, blocking version of this function, see
321 	 * g_output_stream_write().
322 	 * Params:
323 	 * buffer = the buffer containing the data to write. [array length=count][element-type guint8]
324 	 * count = the number of bytes to write
325 	 * ioPriority = the io priority of the request.
326 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
327 	 * callback = callback to call when the request is satisfied. [scope async]
328 	 * userData = the data to pass to callback function. [closure]
329 	 */
330 	public void writeAsync(void* buffer, gsize count, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
331 	{
332 		// void g_output_stream_write_async (GOutputStream *stream,  const void *buffer,  gsize count,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
333 		g_output_stream_write_async(gOutputStream, buffer, count, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
334 	}
335 	
336 	/**
337 	 * Finishes a stream write operation.
338 	 * Params:
339 	 * result = a GAsyncResult.
340 	 * Returns: a gssize containing the number of bytes written to the stream.
341 	 * Throws: GException on failure.
342 	 */
343 	public gssize writeFinish(AsyncResultIF result)
344 	{
345 		// gssize g_output_stream_write_finish (GOutputStream *stream,  GAsyncResult *result,  GError **error);
346 		GError* err = null;
347 		
348 		auto p = g_output_stream_write_finish(gOutputStream, (result is null) ? null : result.getAsyncResultTStruct(), &err);
349 		
350 		if (err !is null)
351 		{
352 			throw new GException( new ErrorG(err) );
353 		}
354 		
355 		return p;
356 	}
357 	
358 	/**
359 	 * Splices a stream asynchronously.
360 	 * When the operation is finished callback will be called.
361 	 * You can then call g_output_stream_splice_finish() to get the
362 	 * result of the operation.
363 	 * For the synchronous, blocking version of this function, see
364 	 * g_output_stream_splice().
365 	 * Params:
366 	 * source = a GInputStream.
367 	 * flags = a set of GOutputStreamSpliceFlags.
368 	 * ioPriority = the io priority of the request.
369 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
370 	 * callback = a GAsyncReadyCallback. [scope async]
371 	 * userData = user data passed to callback. [closure]
372 	 */
373 	public void spliceAsync(InputStream source, GOutputStreamSpliceFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
374 	{
375 		// void g_output_stream_splice_async (GOutputStream *stream,  GInputStream *source,  GOutputStreamSpliceFlags flags,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
376 		g_output_stream_splice_async(gOutputStream, (source is null) ? null : source.getInputStreamStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
377 	}
378 	
379 	/**
380 	 * Finishes an asynchronous stream splice operation.
381 	 * Params:
382 	 * result = a GAsyncResult.
383 	 * Returns: a gssize of the number of bytes spliced. Note that if the number of bytes spliced is greater than G_MAXSSIZE, then that will be returned, and there is no way to determine the actual number of bytes spliced.
384 	 * Throws: GException on failure.
385 	 */
386 	public gssize spliceFinish(AsyncResultIF result)
387 	{
388 		// gssize g_output_stream_splice_finish (GOutputStream *stream,  GAsyncResult *result,  GError **error);
389 		GError* err = null;
390 		
391 		auto p = g_output_stream_splice_finish(gOutputStream, (result is null) ? null : result.getAsyncResultTStruct(), &err);
392 		
393 		if (err !is null)
394 		{
395 			throw new GException( new ErrorG(err) );
396 		}
397 		
398 		return p;
399 	}
400 	
401 	/**
402 	 * Forces an asynchronous write of all user-space buffered data for
403 	 * the given stream.
404 	 * For behaviour details see g_output_stream_flush().
405 	 * When the operation is finished callback will be
406 	 * called. You can then call g_output_stream_flush_finish() to get the
407 	 * result of the operation.
408 	 * Params:
409 	 * ioPriority = the io priority of the request.
410 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
411 	 * callback = a GAsyncReadyCallback to call when the request is satisfied. [scope async]
412 	 * userData = the data to pass to callback function. [closure]
413 	 */
414 	public void flushAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
415 	{
416 		// void g_output_stream_flush_async (GOutputStream *stream,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
417 		g_output_stream_flush_async(gOutputStream, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
418 	}
419 	
420 	/**
421 	 * Finishes flushing an output stream.
422 	 * Params:
423 	 * result = a GAsyncResult.
424 	 * Returns: TRUE if flush operation succeeded, FALSE otherwise.
425 	 * Throws: GException on failure.
426 	 */
427 	public int flushFinish(AsyncResultIF result)
428 	{
429 		// gboolean g_output_stream_flush_finish (GOutputStream *stream,  GAsyncResult *result,  GError **error);
430 		GError* err = null;
431 		
432 		auto p = g_output_stream_flush_finish(gOutputStream, (result is null) ? null : result.getAsyncResultTStruct(), &err);
433 		
434 		if (err !is null)
435 		{
436 			throw new GException( new ErrorG(err) );
437 		}
438 		
439 		return p;
440 	}
441 	
442 	/**
443 	 * Requests an asynchronous close of the stream, releasing resources
444 	 * related to it. When the operation is finished callback will be
445 	 * called. You can then call g_output_stream_close_finish() to get
446 	 * the result of the operation.
447 	 * For behaviour details see g_output_stream_close().
448 	 * The asyncronous methods have a default fallback that uses threads
449 	 * to implement asynchronicity, so they are optional for inheriting
450 	 * classes. However, if you override one you must override all.
451 	 * Params:
452 	 * ioPriority = the io priority of the request.
453 	 * cancellable = optional cancellable object. [allow-none]
454 	 * callback = callback to call when the request is satisfied. [scope async]
455 	 * userData = the data to pass to callback function. [closure]
456 	 */
457 	public void closeAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
458 	{
459 		// void g_output_stream_close_async (GOutputStream *stream,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
460 		g_output_stream_close_async(gOutputStream, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
461 	}
462 	
463 	/**
464 	 * Closes an output stream.
465 	 * Params:
466 	 * result = a GAsyncResult.
467 	 * Returns: TRUE if stream was successfully closed, FALSE otherwise.
468 	 * Throws: GException on failure.
469 	 */
470 	public int closeFinish(AsyncResultIF result)
471 	{
472 		// gboolean g_output_stream_close_finish (GOutputStream *stream,  GAsyncResult *result,  GError **error);
473 		GError* err = null;
474 		
475 		auto p = g_output_stream_close_finish(gOutputStream, (result is null) ? null : result.getAsyncResultTStruct(), &err);
476 		
477 		if (err !is null)
478 		{
479 			throw new GException( new ErrorG(err) );
480 		}
481 		
482 		return p;
483 	}
484 	
485 	/**
486 	 * Checks if an output stream is being closed. This can be
487 	 * used inside e.g. a flush implementation to see if the
488 	 * flush (or other i/o operation) is called from within
489 	 * the closing operation.
490 	 * Since 2.24
491 	 * Returns: TRUE if stream is being closed. FALSE otherwise.
492 	 */
493 	public int isClosing()
494 	{
495 		// gboolean g_output_stream_is_closing (GOutputStream *stream);
496 		return g_output_stream_is_closing(gOutputStream);
497 	}
498 	
499 	/**
500 	 * Checks if an output stream has already been closed.
501 	 * Returns: TRUE if stream is closed. FALSE otherwise.
502 	 */
503 	public int isClosed()
504 	{
505 		// gboolean g_output_stream_is_closed (GOutputStream *stream);
506 		return g_output_stream_is_closed(gOutputStream);
507 	}
508 	
509 	/**
510 	 * Checks if an ouput stream has pending actions.
511 	 * Returns: TRUE if stream has pending actions.
512 	 */
513 	public int hasPending()
514 	{
515 		// gboolean g_output_stream_has_pending (GOutputStream *stream);
516 		return g_output_stream_has_pending(gOutputStream);
517 	}
518 	
519 	/**
520 	 * Sets stream to have actions pending. If the pending flag is
521 	 * already set or stream is closed, it will return FALSE and set
522 	 * error.
523 	 * Returns: TRUE if pending was previously unset and is now set.
524 	 * Throws: GException on failure.
525 	 */
526 	public int setPending()
527 	{
528 		// gboolean g_output_stream_set_pending (GOutputStream *stream,  GError **error);
529 		GError* err = null;
530 		
531 		auto p = g_output_stream_set_pending(gOutputStream, &err);
532 		
533 		if (err !is null)
534 		{
535 			throw new GException( new ErrorG(err) );
536 		}
537 		
538 		return p;
539 	}
540 	
541 	/**
542 	 * Clears the pending flag on stream.
543 	 */
544 	public void clearPending()
545 	{
546 		// void g_output_stream_clear_pending (GOutputStream *stream);
547 		g_output_stream_clear_pending(gOutputStream);
548 	}
549 	
550 	/**
551 	 * Tries to write the data from bytes into the stream. Will block
552 	 * during the operation.
553 	 * If bytes is 0-length, returns 0 and does nothing. A GBytes larger
554 	 * than G_MAXSSIZE will cause a G_IO_ERROR_INVALID_ARGUMENT error.
555 	 * On success, the number of bytes written to the stream is returned.
556 	 * It is not an error if this is not the same as the requested size, as it
557 	 * can happen e.g. on a partial I/O error, or if there is not enough
558 	 * storage in the stream. All writes block until at least one byte
559 	 * is written or an error occurs; 0 is never returned (unless
560 	 * the size of bytes is 0).
561 	 * If cancellable is not NULL, then the operation can be cancelled by
562 	 * triggering the cancellable object from another thread. If the operation
563 	 * was cancelled, the error G_IO_ERROR_CANCELLED will be returned. If an
564 	 * operation was partially finished when the operation was cancelled the
565 	 * partial result will be returned, without an error.
566 	 * On error -1 is returned and error is set accordingly.
567 	 * Params:
568 	 * bytes = the GBytes to write
569 	 * cancellable = optional cancellable object. [allow-none]
570 	 * Returns: Number of bytes written, or -1 on error
571 	 * Throws: GException on failure.
572 	 */
573 	public gssize writeBytes(Bytes bytes, Cancellable cancellable)
574 	{
575 		// gssize g_output_stream_write_bytes (GOutputStream *stream,  GBytes *bytes,  GCancellable *cancellable,  GError **error);
576 		GError* err = null;
577 		
578 		auto p = g_output_stream_write_bytes(gOutputStream, (bytes is null) ? null : bytes.getBytesStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
579 		
580 		if (err !is null)
581 		{
582 			throw new GException( new ErrorG(err) );
583 		}
584 		
585 		return p;
586 	}
587 	
588 	/**
589 	 * Request an asynchronous write of the data in bytes to the stream.
590 	 * When the operation is finished callback will be called. You can
591 	 * then call g_output_stream_write_bytes_finish() to get the result of
592 	 * the operation.
593 	 * During an async request no other sync and async calls are allowed,
594 	 * and will result in G_IO_ERROR_PENDING errors.
595 	 * A GBytes larger than G_MAXSSIZE will cause a
596 	 * G_IO_ERROR_INVALID_ARGUMENT error.
597 	 * On success, the number of bytes written will be passed to the
598 	 * callback. It is not an error if this is not the same as the
599 	 * requested size, as it can happen e.g. on a partial I/O error,
600 	 * but generally we try to write as many bytes as requested.
601 	 * You are guaranteed that this method will never fail with
602 	 * G_IO_ERROR_WOULD_BLOCK - if stream can't accept more data, the
603 	 * method will just wait until this changes.
604 	 * Any outstanding I/O request with higher priority (lower numerical
605 	 * value) will be executed before an outstanding request with lower
606 	 * priority. Default priority is G_PRIORITY_DEFAULT.
607 	 * For the synchronous, blocking version of this function, see
608 	 * g_output_stream_write_bytes().
609 	 * Params:
610 	 * bytes = The bytes to write
611 	 * ioPriority = the io priority of the request.
612 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
613 	 * callback = callback to call when the request is satisfied. [scope async]
614 	 * userData = the data to pass to callback function. [closure]
615 	 */
616 	public void writeBytesAsync(Bytes bytes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
617 	{
618 		// void g_output_stream_write_bytes_async (GOutputStream *stream,  GBytes *bytes,  int io_priority,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
619 		g_output_stream_write_bytes_async(gOutputStream, (bytes is null) ? null : bytes.getBytesStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
620 	}
621 	
622 	/**
623 	 * Finishes a stream write-from-GBytes operation.
624 	 * Params:
625 	 * result = a GAsyncResult.
626 	 * Returns: a gssize containing the number of bytes written to the stream.
627 	 * Throws: GException on failure.
628 	 */
629 	public gssize writeBytesFinish(AsyncResultIF result)
630 	{
631 		// gssize g_output_stream_write_bytes_finish (GOutputStream *stream,  GAsyncResult *result,  GError **error);
632 		GError* err = null;
633 		
634 		auto p = g_output_stream_write_bytes_finish(gOutputStream, (result is null) ? null : result.getAsyncResultTStruct(), &err);
635 		
636 		if (err !is null)
637 		{
638 			throw new GException( new ErrorG(err) );
639 		}
640 		
641 		return p;
642 	}
643 }