TnyStream

TnyStream — A type that defines a stream

Synopsis




                    TnyStream;
                    TnyStreamIface;
gssize              tny_stream_read                     (TnyStream *self,
                                                         char *buffer,
                                                         gsize n);
gssize              tny_stream_write                    (TnyStream *self,
                                                         const char *buffer,
                                                         gsize n);
gint                tny_stream_flush                    (TnyStream *self);
gint                tny_stream_close                    (TnyStream *self);
gboolean            tny_stream_is_eos                   (TnyStream *self);
gint                tny_stream_reset                    (TnyStream *self);
gssize              tny_stream_write_to_stream          (TnyStream *self,
                                                         TnyStream *output);

Object Hierarchy


  GInterface
   +----TnyStream

Known Implementations

TnyStream is implemented by TnyCamelStream, TnyFsStream, TnyMozEmbedStream, TnyCamelMemStream, TnyVfsStream, TnyGtkPixbufStream and TnyGtkTextBufferStream.

Description

A stream is an object that can be written to and can be read from in a streaming fashion.

Details

TnyStream

typedef struct _TnyStream TnyStream;

A stream type

free-function: g_object_unref


TnyStreamIface

typedef struct {
	GTypeInterface parent;

	gssize (*read) (TnyStream *self, char *buffer, gsize n);
	gssize (*write) (TnyStream *self, const char *buffer, gsize n);
	gint (*flush) (TnyStream *self);
	gint (*close) (TnyStream *self);
	gboolean (*is_eos) (TnyStream *self);
	gint (*reset) (TnyStream *self);
	gssize (*write_to_stream) (TnyStream *self, TnyStream *output);
} TnyStreamIface;


tny_stream_read ()

gssize              tny_stream_read                     (TnyStream *self,
                                                         char *buffer,
                                                         gsize n);

Read n bytes from self and write it into buffer. It's your responsibility to pass a buffer that is large enough to hold n bytes.

self : a TnyStream
buffer : a buffer that is at least n in size
n : the max amount of bytes to read from self and to write into buffer
Returns : the number of bytes actually read, or -1 on error and set errno.

Since 1.0 audience: application-developer


tny_stream_write ()

gssize              tny_stream_write                    (TnyStream *self,
                                                         const char *buffer,
                                                         gsize n);

Write n bytes of buffer into self. It's your responsibility to pass a buffer that has at least n bytes.

self : a TnyStream
buffer : a buffer that has at least n bytes
n : the amount of bytes to read from buffer and to write to self
Returns : the number of bytes written to the stream, or -1 on error along with setting errno.

Since 1.0 audience: application-developer


tny_stream_flush ()

gint                tny_stream_flush                    (TnyStream *self);

Flushes any buffered data to the stream's backing store.

self : a TnyStream
Returns : 0 on success or -1 on fail along with setting errno.

Since 1.0 audience: application-developer


tny_stream_close ()

gint                tny_stream_close                    (TnyStream *self);

Closes the stream

self : a TnyStream
Returns : 0 on success or -1 on fail.

Since 1.0 audience: application-developer


tny_stream_is_eos ()

gboolean            tny_stream_is_eos                   (TnyStream *self);

Tests if there are bytes left to read on self.

self : a TnyStream
Returns : TRUE on EOS or FALSE otherwise.

Since 1.0 audience: application-developer


tny_stream_reset ()

gint                tny_stream_reset                    (TnyStream *self);

Resets self. That is, put it in a state where it can be read from the beginning again.

self : a TnyStream
Returns : 0 on success or -1 on error along with setting errno.

Since 1.0 audience: application-developer


tny_stream_write_to_stream ()

gssize              tny_stream_write_to_stream          (TnyStream *self,
                                                         TnyStream *output);

Write self to output in an efficient way

self : a TnyStream
output : a TnyStream
Returns : the number of bytes written to the output stream, or -1 on error along with setting errno.

Since 1.0 audience: application-developer

See Also

TnyCamelStream, TnyStreamCamel, TnyMozEmbedStream, TnyGtkTextBufferStream, TnyFsStream, TnyVfsStream