summaryrefslogtreecommitdiffstats
path: root/docs/reference/pygio-inputstream.xml
blob: b1807e5050a8f53adc0c165ab1cb823019b63dae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-gioinputstream">
    <refnamediv>
        <refname>gio.InputStream</refname>
        <refpurpose>Base class for implementing streaming input</refpurpose>
    </refnamediv>

    <refsect1>
        <title>Synopsis</title>

    <classsynopsis language="python">
        <ooclass><classname>gio.InputStream</classname></ooclass>
        <ooclass><classname><link linkend="class-gobject">gobject.GObject</link></classname></ooclass>

    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--clear-pending">clear_pending</link></methodname>
        <methodparam></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--close">close</link></methodname>
        <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--close-async">close_async</link></methodname>
        <methodparam><parameter role="keyword">callback</parameter></methodparam>
        <methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam>
        <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
        <methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--close-finish">close_finish</link></methodname>
        <methodparam><parameter role="keyword">result</parameter></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--has-pending">has_pending</link></methodname>
        <methodparam></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--is-closed">is_closed</link></methodname>
        <methodparam></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--read">read</link></methodname>
        <methodparam><parameter role="keyword">count</parameter><initializer>-1</initializer></methodparam>
        <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--read-async">read_async</link></methodname>
        <methodparam><parameter role="keyword">count</parameter></methodparam>
        <methodparam><parameter role="keyword">callback</parameter></methodparam>
        <methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam>
        <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
        <methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--read-finish">read_finish</link></methodname>
        <methodparam><parameter role="keyword">result</parameter></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--read-part">read_part</link></methodname>
        <methodparam><parameter role="keyword">count</parameter><initializer>-1</initializer></methodparam>
        <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--set-pending">set_pending</link></methodname>
        <methodparam></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--skip">skip</link></methodname>
        <methodparam><parameter role="keyword">count</parameter></methodparam>
        <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--skip-async">skip_async</link></methodname>
        <methodparam><parameter role="keyword">count</parameter></methodparam>
        <methodparam><parameter role="keyword">callback</parameter></methodparam>
        <methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam>
        <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
        <methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioinputstream--skip-finish">skip_finish</link></methodname>
        <methodparam><parameter role="keyword">result</parameter></methodparam>
    </methodsynopsis>

    </classsynopsis>

    </refsect1>

    <refsect1>
        <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
  +-- <link linkend="class-gioinputstream">gio.InputStream</link>
</synopsis>

    </refsect1>

    <refsect1>
        <title>Description</title>

        <para>
            <link linkend="class-gioinputstream"><classname>gio.InputStream</classname></link>
            has functions to read from a stream (
            <methodname><link linkend="method-gioinputstream--read">gio.InputStream.read</link></methodname>()
            ), to close a stream (
            <methodname><link linkend="method-gioinputstream--close">gio.InputStream.close</link></methodname>()
            ) and to skip some content (
            <methodname><link linkend="method-gioinputstream--skip">gio.InputStream.skip</link></methodname>()
            ).
        </para>
        <para>
            To copy the content of an input stream to an output stream without manually
            handling the reads and writes, use
            <methodname><link linkend="method-giooutputstream--skip">gio.OutputStream.splice</link></methodname>().
        </para>
        <para>
            All of these functions have async variants too.
        </para>
    </refsect1>

    <refsect1>
        <title>Methods</title>

        <refsect2 id="method-gioinputstream--clear-pending">
            <title>gio.InputStream.clear_pending</title>

            <programlisting><methodsynopsis language="python">
                <methodname>clear_pending</methodname>
                <methodparam></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
            </variablelist>
    
            <para>
                The <methodname>clear_pending</methodname>() method clears the pending flag on stream.
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--close">
            <title>gio.InputStream.close</title>

            <programlisting><methodsynopsis language="python">
                <methodname>close</methodname>
                <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                  <term><parameter role="keyword">cancellable</parameter>&nbsp;:</term>
                  <listitem><simpara>optional
                    <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
                    object, <literal>None</literal> to ignore.
                  </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara><literal>True</literal> on success
                    <literal>False</literal> on failure.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>close</methodname>() method closes the stream, releasing
                resources related to it.
            </para>
            <para>
                Once the stream is closed, all other operations will return gio.IO_ERROR_CLOSED.
                Closing a stream multiple times will not return an error.
            </para>
            <para>
                Streams will be automatically closed when the last reference is dropped, but
                you might want to call this function to make sure resources are released as
                early as possible.
            </para>
            <para>
                Some streams might keep the backing store of the stream (e.g. a file descriptor)
                open after the stream is closed. See the documentation for the individual
                stream for details.
            </para>
            <para>
                On failure the first error that happened will be reported, but the close operation
                will finish as much as possible. A stream that failed to close will still return
                gio.IO_ERROR_CLOSED for all operations. Still, it is important to check and report
                the error to the user.
            </para>
            <para>
                If cancellable is not <literal>None</literal>, then the operation can be cancelled by
                triggering the cancellable object from another thread. If the operation was cancelled,
                the error gio.IO_ERROR_CANCELLED will be returned. Cancelling a close will still leave
                the stream closed, but some streams can use a faster close that doesn't block to e.g.
                check errors.
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--close-async">
            <title>gio.InputStream.close_async</title>

            <programlisting><methodsynopsis language="python">
                <methodname>close_async</methodname>
                <methodparam><parameter role="keyword">callback</parameter></methodparam>
                <methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam>
                <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
                <methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><parameter>callback</parameter>&nbsp;:</term>
                    <listitem><simpara>a GAsyncReadyCallback to call when the request is satisfied.
                    </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>io_priority</parameter>&nbsp;:</term>
                    <listitem><simpara>the
                    <xref linkend="glib-priority-constants" endterm="glib-priority-constants-title"></xref>
                    of the request. 
                    </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>cancellable</parameter>&nbsp;:</term>
                    <listitem><simpara>optional
                    <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
                    object, <literal>None</literal> to ignore.</simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>user_data</parameter>&nbsp;:</term>
                    <listitem><simpara>the data to pass to callback function.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>close_async</methodname>() method asynchronously requests an
                asynchronous closes of the stream, releasing resources related to it.
            </para>
            <para>
                For more details, see
                <methodname><link linkend="method-gioinputstream--close">gio.InputStream.close</link></methodname>()
                which is the synchronous version of this call. 
            </para>
            <para>
                When the operation is finished, callback will be called. You can then call
                <methodname><link linkend="method-gioinputstream--close-finish">gio.InputStream.close_finish</link></methodname>()
                to get the result of the operation.
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--close-finish">
            <title>gio.InputStream.close_finish</title>

            <programlisting><methodsynopsis language="python">
                <methodname>close_finish</methodname>
                <methodparam><parameter role="keyword">result</parameter></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                  <term><parameter role="keyword">result</parameter>&nbsp;:</term>
                  <listitem><simpara>a <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>.
                  </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara><literal>True</literal> if the stream was closed successfully.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>close_finish</methodname>() method finishes an asynchronous
                file append operation started with
                <methodname><link linkend="method-gioinputstream--close-async">gio.InputStream.close_async</link></methodname>().
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--has-pending">
            <title>gio.InputStream.has_pending</title>

            <programlisting><methodsynopsis language="python">
                <methodname>has_pending</methodname>
                <methodparam></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara><literal>True</literal> if stream has pending actions.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>has_pending</methodname>() method checks if an input stream has pending actions.
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--is-closed">
            <title>gio.InputStream.is_closed</title>

            <programlisting><methodsynopsis language="python">
                <methodname>is_closed</methodname>
                <methodparam></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara><literal>True</literal> if the stream is closed.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>is_closed</methodname>() method checks if an input stream is closed.
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--read">
            <title>gio.InputStream.read</title>

            <programlisting><methodsynopsis language="python">
                <methodname>read</methodname>
                <methodparam><parameter role="keyword">count</parameter><initializer>-1</initializer></methodparam>
                <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                  <term><parameter role="keyword">count</parameter>&nbsp;:</term>
                  <listitem><simpara>optionally the number of bytes that will be read from the stream.
                  </simpara></listitem>
                </varlistentry>
                <varlistentry>
                  <term><parameter role="keyword">cancellable</parameter>&nbsp;:</term>
                  <listitem><simpara>optional
                    <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
                    object, <literal>None</literal> to ignore.
                  </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara>The number of bytes read, or -1 on error.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>read</methodname>() method tries to read count bytes from
                the stream into the buffer starting at buffer. Will block during this read.
            </para>
            <para>
                This function is similar to
                <methodname><link linkend="method-gioinputstream--read-part">gio.InputStream.read_part</link></methodname>(),
                except it tries to read as many bytes as requested, only stopping on an error or end of stream.
            </para>
            <para>
                On a successful read of count bytes, or if we reached the end of the stream,
                <literal>True</literal> is returned, and bytes_read is set to the number of bytes read into buffer.
            </para>
            <para>
                If cancellable is not <literal>None</literal>, then the operation can be cancelled by
                triggering the cancellable object from another thread. If the operation was cancelled,
                the error gio.IO_ERROR_CANCELLED will be returned. Cancelling a close will still leave
                the stream closed, but some streams can use a faster close that doesn't block to e.g.
                check errors.
            </para>
            <para>
                If there is an error during the operation <literal>False</literal> is returned and error
                is set to indicate the error status, bytes_read is updated to contain the number of
                bytes read into buffer before the error occurred.
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--read-async">
            <title>gio.InputStream.read_async</title>

            <programlisting><methodsynopsis language="python">
                <methodname>read_async</methodname>
                <methodparam><parameter role="keyword">count</parameter></methodparam>
                <methodparam><parameter role="keyword">callback</parameter></methodparam>
                <methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam>
                <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
                <methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><parameter>count</parameter>&nbsp;:</term>
                    <listitem><simpara>the number of bytes that will be read from the stream.
                    </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>callback</parameter>&nbsp;:</term>
                    <listitem><simpara>a GAsyncReadyCallback to call when the request is satisfied.
                    </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>io_priority</parameter>&nbsp;:</term>
                    <listitem><simpara>the
                    <xref linkend="glib-priority-constants" endterm="glib-priority-constants-title"></xref>
                    of the request. 
                    </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>cancellable</parameter>&nbsp;:</term>
                    <listitem><simpara>optional
                    <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
                    object, <literal>None</literal> to ignore.</simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>user_data</parameter>&nbsp;:</term>
                    <listitem><simpara>the data to pass to callback function.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>read_async</methodname>() method requests an asynchronous read
                of count bytes from the stream into the buffer.
            </para>
            <para>
                For more details, see
                <methodname><link linkend="method-gioinputstream--read">gio.InputStream.read</link></methodname>()
                which is the synchronous version of this call. 
            </para>
            <para>
                When the operation is finished, callback will be called. You can then call
                <methodname><link linkend="method-gioinputstream--read-finish">gio.InputStream.read_finish</link></methodname>()
                to get the result of the operation.
            </para>
            <para>
                During an async request no other sync and async calls are allowed, and
                will result in gio.IO_ERROR_PENDING errors.
            </para>
            <para>
                A value of count larger than G_MAXSSIZE will cause a gio.IO_ERROR_INVALID_ARGUMENT error.
            </para>
            <para>
                On success, the number of bytes read into the buffer will be passed to the callback.
                It is not an error if this is not the same as the requested size, as it can happen e.g.
                near the end of a file, but generally we try to read as many bytes as requested. Zero
                is returned on end of file (or if count is zero), but never otherwise.
            </para>
            <para>
                Any outstanding i/o request with higher priority (lower numerical value) will be
                executed before an outstanding request with lower priority. Default priority is glib.PRIORITY_DEFAULT.
            </para>
            <para>
                The asyncronous methods have a default fallback that uses threads to implement asynchronicity, so
                they are optional for inheriting classes. However, if you override one you must override all.
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--read-finish">
            <title>gio.InputStream.read_finish</title>

            <programlisting><methodsynopsis language="python">
                <methodname>read_finish</methodname>
                <methodparam><parameter role="keyword">result</parameter></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                  <term><parameter role="keyword">result</parameter>&nbsp;:</term>
                  <listitem><simpara>a <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>.
                  </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara>The number of bytes read in, or -1 on error.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>read_finish</methodname>() method finishes an asynchronous
                stream read operation started by
                <methodname><link linkend="method-gioinputstream--read-async">gio.InputStream.read_async</link></methodname>().
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--read-part">
            <title>gio.InputStream.read_part</title>

            <programlisting><methodsynopsis language="python">
                <methodname>read_part</methodname>
                <methodparam><parameter role="keyword">count</parameter><initializer>-1</initializer></methodparam>
                <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                  <term><parameter role="keyword">count</parameter>&nbsp;:</term>
                  <listitem><simpara>optionally the number of bytes that will be read from the stream.
                  </simpara></listitem>
                </varlistentry>
                <varlistentry>
                  <term><parameter role="keyword">cancellable</parameter>&nbsp;:</term>
                  <listitem><simpara>optional
                    <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
                    object, <literal>None</literal> to ignore.
                  </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara>The number of bytes read, or -1 on error.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>read_part</methodname>() method tries to read count bytes from
                the stream into the buffer starting at buffer. Will block during this read.
            </para>
            <para>
                If count is zero returns zero and does nothing. A value of count larger than
                G_MAXSSIZE will cause a gio.IO_ERROR_INVALID_ARGUMENT error.
            </para>
            <para>
                On success, the number of bytes read into the buffer is returned. It is
                not an error if this is not the same as the requested size, as it can
                happen e.g. near the end of a file. Zero is returned on end of file
                (or if count is zero), but never otherwise.
            </para>
            <para>
               If cancellable is not <literal>None</literal>, then the operation can be cancelled by
                triggering the cancellable object from another thread. If the operation was cancelled,
                the error gio.IO_ERROR_CANCELLED will be returned. Cancelling a close will still leave
                the stream closed, but some streams can use a faster close that doesn't block to e.g.
                check errors.
            </para>
            <para>
                On error -1 is returned and error is set accordingly.
            </para>
            <note>
                This method roughly corresponds to C GIO g_input_stream_read.
            </note>
        </refsect2>

        <refsect2 id="method-gioinputstream--set-pending">
            <title>gio.InputStream.set_pending</title>

            <programlisting><methodsynopsis language="python">
                <methodname>set_pending</methodname>
                <methodparam></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara><literal>True</literal> if pending was previously
                    unset and is now set.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>set_pending</methodname>() method sets stream to have actions pending.
                If the pending flag is already set or stream is closed,
                it will return <literal>False</literal> and set error.
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--skip">
            <title>gio.InputStream.skip</title>

            <programlisting><methodsynopsis language="python">
                <methodname>skip</methodname>
                <methodparam><parameter role="keyword">count</parameter></methodparam>
                <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                  <term><parameter role="keyword">count</parameter>&nbsp;:</term>
                  <listitem><simpara>the number of bytes that will be skipped from the stream.
                  </simpara></listitem>
                </varlistentry>
                <varlistentry>
                  <term><parameter role="keyword">cancellable</parameter>&nbsp;:</term>
                  <listitem><simpara>optional
                    <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
                    object, <literal>None</literal> to ignore.
                  </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara>The number of bytes skipped, or -1 on error
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>skip</methodname>() method tries to skip count bytes
                from the stream. Will block during the operation.
            </para>
            <para>
                This is identical to
                <methodname><link linkend="method-gioinputstream--read">read</link></methodname>(),
                from a behaviour standpoint, but the bytes that are skipped are not
                returned to the user. Some streams have an implementation that is more
                efficient than reading the data.
            </para>
            <para>
                This function is optional for inherited classes, as the default implementation emulates it using read.
            </para>
            <para>
               If cancellable is not <literal>None</literal>, then the operation can be cancelled by
                triggering the cancellable object from another thskip. If the operation was cancelled,
                the error gio.IO_ERROR_CANCELLED will be returned. Cancelling a close will still leave
                the stream closed, but some streams can use a faster close that doesn't block to e.g.
                check errors.
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--skip-async">
            <title>gio.InputStream.skip_async</title>

            <programlisting><methodsynopsis language="python">
                <methodname>skip_async</methodname>
                <methodparam><parameter role="keyword">count</parameter></methodparam>
                <methodparam><parameter role="keyword">callback</parameter></methodparam>
                <methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam>
                <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
                <methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><parameter>count</parameter>&nbsp;:</term>
                    <listitem><simpara>the number of bytes that will be skipped from the stream.
                    </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>callback</parameter>&nbsp;:</term>
                    <listitem><simpara>a GAsyncskipyCallback to call when the request is satisfied.
                    </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>io_priority</parameter>&nbsp;:</term>
                    <listitem><simpara>the
                    <xref linkend="glib-priority-constants" endterm="glib-priority-constants-title"></xref>
                    of the request. 
                    </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>cancellable</parameter>&nbsp;:</term>
                    <listitem><simpara>optional
                    <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
                    object, <literal>None</literal> to ignore.</simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><parameter>user_data</parameter>&nbsp;:</term>
                    <listitem><simpara>the data to pass to callback function.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>skip_async</methodname>() method request an asynchronous
                skip of count bytes from the stream.
            </para>
            <para>
                For more details, see
                <methodname><link linkend="method-gioinputstream--skip">gio.InputStream.skip</link></methodname>()
                which is the synchronous version of this call. 
            </para>
            <para>
                When the operation is finished, callback will be called. You can then call
                <methodname><link linkend="method-gioinputstream--skip-finish">gio.InputStream.skip_finish</link></methodname>()
                to get the result of the operation.
            </para>
            <para>
                During an async request no other sync and async calls are allowed, and
                will result in gio.IO_ERROR_PENDING errors.
            </para>
            <para>
                A value of count larger than G_MAXSSIZE will cause a gio.IO_ERROR_INVALID_ARGUMENT error.
            </para>
            <para>
                On success, the number of bytes skipped will be passed to the callback. It is
                not an error if this is not the same as the requested size, as it can happen
                e.g. near the end of a file, but generally we try to skip as many bytes as requested.
                Zero is returned on end of file (or if count is zero), but never otherwise.
            </para>
            <para>
                Any outstanding i/o request with higher priority (lower numerical value) will be
                executed before an outstanding request with lower priority. Default priority is glib.PRIORITY_DEFAULT.
            </para>
            <para>
                The asyncronous methods have a default fallback that uses thskips to implement asynchronicity, so
                they are optional for inheriting classes. However, if you override one you must override all.
            </para>
        </refsect2>

        <refsect2 id="method-gioinputstream--skip-finish">
            <title>gio.InputStream.skip_finish</title>

            <programlisting><methodsynopsis language="python">
                <methodname>skip_finish</methodname>
                <methodparam><parameter role="keyword">result</parameter></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                  <term><parameter role="keyword">result</parameter>&nbsp;:</term>
                  <listitem><simpara>a <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>.
                  </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara>The number of bytes skipped in, or -1 on error.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>skip_finish</methodname>() method finishes an asynchronous
                stream skip operation started by
                <methodname><link linkend="method-gioinputstream--skip-async">gio.InputStream.skip_async</link></methodname>().
            </para>
        </refsect2>
    </refsect1>
</refentry>