A wrapper object offering easy to use buffered streams over existing I/O class.
The idea is that unlike the traditional Efl.Io.Writer which will attempt to write directly and thus may take less data than requested, this one will keep the pending data in its own buffer, feeding to the actual output when Efl.Io.Writer can write. That makes its operation much simpler as Efl.Io.Writer.write will always take the full data -- allows "write and forget", if unlimited (see Efl.Io.Buffered_Stream.max_queue_size_output). When finished writing data Efl.Io.Buffered_Stream.eos_mark then waits for the "write.finished" event to know all data has been sent.
Reading is also much simpler since incoming data is kept in an Efl.Io.Queue, thus its size can be queried with Efl.Io.Buffered_Stream.pending_read and read with Efl.Io.Reader.read or peeked with Efl.Io.Buffered_Stream.slice, then discarded with Efl.Io.Buffered_Stream.discard or Efl.Io.Buffered_Stream.clear.
When waiting for a complete message, just peek at its contents, if not complete do nothing and wait. If complete then use either Efl.Io.Reader.read to get a copy or manipulate a read-only reference from Efl.Io.Buffered_Stream.slice and then Efl.Io.Buffered_Stream.discard.
The actual I/O is set with the constructor method Efl.Io.Buffered_Stream.inner_io.set and can be retrieved with Efl.Io.Buffered_Stream.inner_io.get, which should be used with care -- calling Efl.Io.Reader.read and Efl.Io.Writer.write on it may produce unexpected results.
truewill notify Efl.Io.Reader.read can be called without blocking or failing.
Eina_Bool efl_io_reader_can_read_get(const Eo *obj); void efl_io_reader_can_read_set(Eo *obj, Eina_Bool can_read);
truewill notify Efl.Io.Writer.write can be called without blocking or failing.
Eina_Bool efl_io_writer_can_write_get(const Eo *obj); void efl_io_writer_can_write_set(Eo *obj, Eina_Bool can_write);
Clears the incoming queue. Same as reading all data.
void efl_io_buffered_stream_clear(Eo *obj);
Closes the Input/Output object.
Eina_Error efl_io_closer_close(Eo *obj);
If true will automatically close() on object destructor.
Eina_Bool efl_io_closer_close_on_destructor_get(const Eo *obj); void efl_io_closer_close_on_destructor_set(Eo *obj, Eina_Bool close_on_destructor);
If true will automatically close resources on exec() calls.
Eina_Bool efl_io_closer_close_on_exec_get(const Eo *obj); Eina_Bool efl_io_closer_close_on_exec_set(Eo *obj, Eina_Bool close_on_exec);
If true will notify object was closed.
Eina_Bool efl_io_closer_closed_get(const Eo *obj); Eina_Bool efl_io_closer_closed_set(Eo *obj, Eina_Bool is_closed);
Call the object's destructor.
void efl_destructor(Eo *obj);
Discards the given number of bytes.
void efl_io_buffered_stream_discard(Eo *obj, size_t amount);
truewill notify end of stream.
Eina_Bool efl_io_reader_eos_get(const Eo *obj); void efl_io_reader_eos_set(Eo *obj, Eina_Bool is_eos);
Marks the end-of-stream. Signals nothing else will be written.
void efl_io_buffered_stream_eos_mark(Eo *obj);
Called at the end of efl_add. Should not be called, just overridden.
Efl_Object *efl_finalize(Eo *obj);
Forces writing all pending data to destination.
Eina_Bool efl_io_buffered_stream_flush(Eo *obj, Eina_Bool may_block, Eina_Bool ignore_line_delimiter);
inner_io (get, set)
The inner I/O this wrapper operates on.
Efl_Object *efl_io_buffered_stream_inner_io_get(const Eo *obj); void efl_io_buffered_stream_inner_io_set(Eo *obj, Efl_Object *io);
line_delimiter (get, set)
If set incoming data will be checked for the delimiter and "line" events. The line may include the delimiter, unless it's end-of-stream in Efl.Io.Buffered_Stream.max_queue_size_input has been reached.
const Eina_Slice efl_io_buffered_stream_line_delimiter_get(const Eo *obj); void efl_io_buffered_stream_line_delimiter_set(Eo *obj, const Eina_Slice slice);
max_queue_size_input (get, set)
Limits how big the input queue can grow, in bytes.
size_t efl_io_buffered_stream_max_queue_size_input_get(const Eo *obj); void efl_io_buffered_stream_max_queue_size_input_set(Eo *obj, size_t max_queue_size_input);
max_queue_size_output (get, set)
Limits how big the output queue can grow in bytes.
size_t efl_io_buffered_stream_max_queue_size_output_get(const Eo *obj); void efl_io_buffered_stream_max_queue_size_output_set(Eo *obj, size_t max_queue_size_output);
How many bytes are pending (available) for read
size_t efl_io_buffered_stream_pending_read_get(const Eo *obj);
How many bytes are pending write to Efl.Io.Buffered_Stream.inner_io
size_t efl_io_buffered_stream_pending_write_get(const Eo *obj);
How many bytes were written and read.
void efl_io_buffered_stream_progress_get(const Eo *obj, size_t *read_bytes, size_t *written_bytes);
Reads data into a pre-allocated buffer.
Eina_Error efl_io_reader_read(Eo *obj, Eina_Rw_Slice rw_slice);
read_chunk_size (get, set)
Reads chunk size property, in bytes.
size_t efl_io_buffered_stream_read_chunk_size_get(const Eo *obj); void efl_io_buffered_stream_read_chunk_size_set(Eo *obj, size_t size);
Gets a temporary access to input queue's internal read memory.
Eina_Slice efl_io_buffered_stream_slice_get(const Eo *obj);
timeout_inactivity (get, set)
Error as ETIMEDOUT if it becomes inactive for some time.
double efl_io_buffered_stream_timeout_inactivity_get(const Eo *obj); void efl_io_buffered_stream_timeout_inactivity_set(Eo *obj, double seconds);
Writes data from a pre-populated buffer.
Eina_Error efl_io_writer_write(Eo *obj, Eina_Slice slice, Eina_Slice *remaining);
|loop (get)||The loop to which this object belongs to.|
|parent (get, set)||The parent of an object.|
|allow_parent_unref (get, set)||Allow an object to be deleted by unref even if it has a parent.|
|children_iterator_new||Get an iterator on all childrens|
|comment (get, set)||A human readable comment for the object|
|composite_attach||Make an object a composite object of another.|
|composite_detach||Detach a composite object from another object.|
|composite_part_is||Check if an object is part of a composite object.|
|constructor||Call the object's constructor.|
|debug_name_override||Build a read-only name for this object used for debugging.|
|del||Unrefs the object and reparents it to NULL.|
|event_callback_forwarder_add||Add an event callback forwarder for an event and an object.|
|event_callback_forwarder_del||Remove an event callback forwarder for an event and an object.|
|event_callback_stop||Stop the current callback call.|
|event_freeze||Freeze events of object.|
|event_freeze_count (get)||Return freeze events of object.|
| ||event_global_freeze||Freeze events of object.|
| ||event_global_freeze_count (get)||Return freeze events of object.|
| ||event_global_thaw||Thaw events of object.|
|event_thaw||Thaw events of object.|
|finalized (get)||True if the object is already finalized, otherwise false.|
|name (get, set)||The name of the object.|
|name_find||Find a child object with the given name and return it.|
|provider_find||Searches upwards in the object tree for a provider which knows the given class/interface.|
An error has occurred and I/O has stopped
Both read and write are finished.
EFL_IO_BUFFERED_STREAM_EVENT_LINE(const Eina_Slice *)
Property Efl.Io.Buffered_Stream.progress changed
Same as Efl.Io.Reader "eos", for consistency.
The read-slice returned by Efl.Io.Buffered_Stream.slice may have changed.
Efl.Io.Buffered_Stream.eos_mark was called and all available data was sent to destination
|closed||Notifies closed, when property is marked as true|
|can_read,changed||Notifies can_read property changed.|
|eos||Notifies end of stream, when property is marked as true.|
|can_write,changed||Notifies can_write property changed.|
|callback,add||A callback was added.|
|callback,del||A callback was deleted.|
|del||Object is being deleted.|
|destruct||Object has been fully destroyed. It can not be used beyond this point. This event should only serve to clean up any dangling pointer.|