## GVirStream GVirStream |

## Synopsis

    struct              GVirStream;
    struct              GVirStreamClass;
    gint                (*GVirStreamSinkFunc)               (GVirStream *stream,
                                                             const gchar *buf,
                                                             gsize nbytes,
                                                             gpointer user_data);
    gint                (*GVirStreamSourceFunc)             (GVirStream *stream,
                                                             gchar *buf,
                                                             gsize nbytes,
                                                             gpointer user_data);
    enum                GVirStreamIOCondition;
    gboolean            (*GVirStreamIOFunc)                 (GVirStream *stream,
                                                             GVirStreamIOCondition cond,
                                                             gpointer opaque);
    guint               gvir_stream_add_watch               (GVirStream *stream,
                                                             GVirStreamIOCondition cond,
                                                             GVirStreamIOFunc func,
                                                             gpointer opaque);
    guint               gvir_stream_add_watch_full          (GVirStream *stream,
                                                             gint priority,
                                                             GVirStreamIOCondition cond,
                                                             GVirStreamIOFunc func,
                                                             gpointer opaque,
                                                             GDestroyNotify notify);
    gssize              gvir_stream_receive_all             (GVirStream *stream,
                                                             GCancellable *cancellable,
                                                             GVirStreamSinkFunc func,
                                                             gpointer user_data,
                                                             GError **error);
    gssize              gvir_stream_receive                 (GVirStream *stream,
                                                             gchar *buffer,
                                                             gsize size,
                                                             GCancellable *cancellable,
                                                             GError **error);
    gssize              gvir_stream_send_all                (GVirStream *stream,
                                                             GCancellable *cancellable,
                                                             GVirStreamSourceFunc func,
                                                             gpointer user_data,
                                                             GError **error);
    gssize              gvir_stream_send                    (GVirStream *stream,
                                                             const gchar *buffer,
                                                             gsize size,
                                                             GCancellable *cancellable,
                                                             GError **error);

## Object Hierarchy

      GObject
       +----GIOStream
             +----GVirStream

## Properties

      "handle"                   GVirStreamHandle*     : Read / Write / Construct Only

## Description

## Details

### struct GVirStream

    struct GVirStream;

### struct GVirStreamClass

    struct GVirStreamClass {
        GIOStreamClass parent_class;

        gpointer padding[20];
    };

### GVirStreamSinkFunc ()

    gint                (*GVirStreamSinkFunc)               (GVirStream *stream,
                                                             const gchar *buf,
                                                             gsize nbytes,
                                                             gpointer user_data);

`stream` : | a GVirStream
`buf` : | data pointer. [out][array length=nbytes][transfer none]
`nbytes` : | data size
`user_data` : | user data passed to the function
Returns : | the number of bytes filled, 0 upon end of file, or -1 upon error

### GVirStreamSourceFunc ()

    gint                (*GVirStreamSourceFunc)             (GVirStream *stream,
                                                             gchar *buf,
                                                             gsize nbytes,
                                                             gpointer user_data);

`stream` : | a GVirStream
`buf` : | data pointer. [out][array length=nbytes][transfer none]
`nbytes` : | data size
`user_data` : | user data passed to the function
Returns : | the number of bytes filled, 0 upon end of file, or -1 upon error

### enum GVirStreamIOCondition

    typedef enum {
        GVIR_STREAM_IO_CONDITION_READABLE = (1 << 0),
        GVIR_STREAM_IO_CONDITION_WRITABLE = (1 << 1),
        GVIR_STREAM_IO_CONDITION_HANGUP   = (1 << 2),
        GVIR_STREAM_IO_CONDITION_ERROR    = (1 << 3),
    } GVirStreamIOCondition;

`GVIR_STREAM_IO_CONDITION_READABLE` |
`GVIR_STREAM_IO_CONDITION_WRITABLE` |
`GVIR_STREAM_IO_CONDITION_HANGUP` |
`GVIR_STREAM_IO_CONDITION_ERROR` |

### GVirStreamIOFunc ()

    gboolean            (*GVirStreamIOFunc)                 (GVirStream *stream,
                                                             GVirStreamIOCondition cond,
                                                             gpointer opaque);

### gvir_stream_add_watch ()

    guint               gvir_stream_add_watch               (GVirStream *stream,
                                                             GVirStreamIOCondition cond,
                                                             GVirStreamIOFunc func,
                                                             gpointer opaque);

Adds a watch for `stream` to the mainloop

`stream` : | the stream
`cond` : | the conditions to watch for (bitfield of GVirStreamIOCondition)
`func` : | the function to call when the condition is satisfied. [closure opaque]
`opaque` : | user data to pass to `func`. [closure]
Returns : | the event source id

### gvir_stream_add_watch_full ()

    guint               gvir_stream_add_watch_full          (GVirStream *stream,
                                                             gint priority,
                                                             GVirStreamIOCondition cond,
                                                             GVirStreamIOFunc func,
                                                             gpointer opaque,
                                                             GDestroyNotify notify);

Adds a watch for `stream` to the mainloop

`stream` : | the stream
`priority` : | the priority of the GVirStream source
`cond` : | the conditions to watch for (bitfield of GVirStreamIOCondition)
`func` : | the function to call when the condition is satisfied. [closure opaque]
`opaque` : | user data to pass to `func`. [closure]
`notify` : | the function to call when the source is removed
Returns : | the event source id Rename to: gvir_stream_add_watch

### gvir_stream_receive_all ()

    gssize              gvir_stream_receive_all             (GVirStream *stream,
                                                             GCancellable *cancellable,
                                                             GVirStreamSinkFunc func,
                                                             gpointer user_data,
                                                             GError **error);

Receive the entire data stream, sending the data to the requested data sink. This is simply a convenient alternative to virStreamRecv, for apps that do blocking-I/o.

`stream` : | the stream
`cancellable` : | cancellation notifier
`func` : | the callback for writing data to application. [scope notified]
`user_data` : | data to be passed to `callback`. [closure]
`error` : | GError for error reporting, or `NULL` to ignore.
Returns : | the number of bytes consumed or -1 upon error

### gvir_stream_receive ()

    gssize              gvir_stream_receive                 (GVirStream *stream,
                                                             gchar *buffer,
                                                             gsize size,
                                                             GCancellable *cancellable,
                                                             GError **error);

Receive data (up to `size` bytes) from a stream. On error -1 is returned and `error` is set accordingly.

`gvir_stream_receive()` can return any number of bytes, up to `size`. If more than `size` bytes have been received, the additional data will be returned in future calls to `gvir_stream_receive()`.

If there is no data available, a `G_IO_ERROR_WOULD_BLOCK` error will be returned.

`stream` : | the stream
`buffer` : | a buffer to read data into (which should be at least `size` bytes long). [array length=size][element-type guint8]
`size` : | the number of bytes you want to read from the stream
`cancellable` : | a `GCancellable` or `NULL`. [allow-none]
`error` : | GError for error reporting, or `NULL` to ignore.
Returns : | Number of bytes read, or 0 if the end of stream reached, or -1 on error.

### gvir_stream_send_all ()

    gssize              gvir_stream_send_all                (GVirStream *stream,
                                                             GCancellable *cancellable,
                                                             GVirStreamSourceFunc func,
                                                             gpointer user_data,
                                                             GError **error);

Send the entire data stream, sending the data to the requested data source. This is simply a convenient alternative to virStreamRecv, for apps that do blocking-I/o.

`stream` : | the stream
`cancellable` : | cancellation notifier
`func` : | the callback for writing data to application. [scope notified]
`user_data` : | data to be passed to `callback`. [closure]
`error` : | GError for error reporting, or `NULL` to ignore.
Returns : | the number of bytes consumed or -1 upon error

### gvir_stream_send ()

    gssize              gvir_stream_send                    (GVirStream *stream,
                                                             const gchar *buffer,
                                                             gsize size,
                                                             GCancellable *cancellable,
                                                             GError **error);

Send data (up to `size` bytes) from a stream. On error -1 is returned and `error` is set accordingly.

`gvir_stream_send()` can return any number of bytes, up to `size`. If more than `size` bytes have been sendd, the additional data will be returned in future calls to `gvir_stream_send()`.

If there is no data available, a `G_IO_ERROR_WOULD_BLOCK` error will be returned.

`stream` : | the stream
`buffer` : | a buffer to write data from (which should be at least `size` bytes long).
`size` : | the number of bytes you want to write to the stream
`cancellable` : | a `GCancellable` or `NULL`. [allow-none]
`error` : | GError for error reporting, or `NULL` to ignore.
Returns : | Number of bytes written.

## Property Details

### The `"handle"` property

      "handle"                   GVirStreamHandle*     : Read / Write / Construct Only

The stream handle.