module IO::Buffered
¶
The IO::Buffered
mixin enhances an IO
with input/output buffering.
The buffering behaviour can be turned on/off with the #sync=
and
#read_buffering=
methods.
Additionally, several methods, like #gets
, are implemented in a more
efficient way.
Direct including types
Compress::Deflate::Reader
Compress::Gzip::Reader
Compress::Zlib::Reader
IO::FileDescriptor
OpenSSL::SSL::Socket
Socket
Methods¶
#buffer_size=(value)
¶
(value)
Set the buffer size of both the read and write buffer Cannot be changed after any of the buffers have been allocated
#flush_on_newline=(flush_on_newline)
¶
(flush_on_newline)
Turns on/off flushing the underlying IO
when a newline is written.
#flush_on_newline?
¶
Determines if this IO
flushes automatically when a newline is written.
#peek : Bytes?
¶
: Bytes?
Returns the bytes hold in the read buffer.
This method only performs a read to return peek data if the current buffer is empty: otherwise no read is performed and whatever is in the buffer is returned.
#sync=(sync)
¶
(sync)
Turns on/off IO
write buffering. When sync is set to true
, no buffering
will be done (that is, writing to this IO
is immediately synced to the
underlying IO
).
abstract
#unbuffered_read(slice : Bytes)
¶
(slice : Bytes)
Reads at most slice.size bytes from the wrapped IO
into slice.
Returns the number of bytes read.
abstract
#unbuffered_write(slice : Bytes)
¶
(slice : Bytes)
Writes at most slice.size bytes from slice into the wrapped IO
.
Returns the number of bytes written.