module IO::Buffered
Overview
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
Defined in:
io/buffered.crInstance Method Summary
- #buffer_size : Int32
Return the buffer size used
- #buffer_size=(value)
Set the buffer size of both the read and write buffer Cannot be changed after any of the buffers have been allocated
- #close : Nil
Flushes and closes the underlying
IO
. - #flush
Flushes any buffered data and the underlying
IO
. - #flush_on_newline=(flush_on_newline)
Turns on/off flushing the underlying
IO
when a newline is written. - #flush_on_newline? : Bool
Determines if this
IO
flushes automatically when a newline is written. - #peek : Bytes?
Returns the bytes hold in the read buffer.
- #read(slice : Bytes) : Int32
Buffered implementation of
IO#read(slice)
. - #read_buffering=(read_buffering)
Turns on/off
IO
read buffering. - #read_buffering? : Bool
Determines whether this
IO
buffers reads. - #rewind
Rewinds the underlying
IO
. - #sync=(sync)
Turns on/off
IO
write buffering. - #sync? : Bool
Determines if this
IO
does write buffering. - #unbuffered_close
Closes the wrapped
IO
. - #unbuffered_flush
Flushes the wrapped
IO
. - #unbuffered_read(slice : Bytes)
Reads at most slice.size bytes from the wrapped
IO
into slice. - #unbuffered_rewind
Rewinds the wrapped
IO
. - #unbuffered_write(slice : Bytes)
Writes at most slice.size bytes from slice into the wrapped
IO
. - #write(slice : Bytes) : Nil
Buffered implementation of
IO#write(slice)
.
Instance Method Detail
def buffer_size=(value)Source
Set the buffer size of both the read and write buffer Cannot be changed after any of the buffers have been allocated
def flush_on_newline=(flush_on_newline)Source
Turns on/off flushing the underlying IO
when a newline is written.
def flush_on_newline? : BoolSource
Determines if this IO
flushes automatically when a newline is written.
def peek : Bytes?Source
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.
def read(slice : Bytes) : Int32Source
Buffered implementation of IO#read(slice)
.
def sync=(sync)Source
abstract def unbuffered_read(slice : Bytes)Source
Reads at most slice.size bytes from the wrapped IO
into slice. Returns the number of bytes read.
abstract def unbuffered_write(slice : Bytes)Source
Writes at most slice.size bytes from slice into the wrapped IO
. Returns the number of bytes written.
def write(slice : Bytes) : NilSource
Buffered implementation of IO#write(slice)
.
© 2012–2021 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/1.2.1/IO/Buffered.html