IO::Buffered

module IO::Buffered

Overview

The IO::Buffered mixin enhances the IO module with input/output buffering.

The buffering behaviour can be turned on/off with the #sync= method.

Additionally, several methods, like #gets, are implemented in a more efficient way.

Included Modules

Direct including types

Defined in:

io/buffered.cr

Constant Summary

BUFFER_SIZE = 8192

Instance Method Summary

Instance methods inherited from module IO

< <<, close close, closed? closed?, each_byte
each_byte(&block) : Nil each_byte
, each_char(&block) : Nil
each_char each_char
, each_line(*args, **options, &block) : Nil
each_line(*args, **options) each_line
, encoding : String encoding, flush flush, gets(limit : Int, chomp = false) : String?
gets(delimiter : Char, chomp = false) : String?
gets(delimiter : String, chomp = false) : String?
gets(chomp = true) : String?
gets(delimiter : Char, limit : Int, chomp = false) : String? gets
, gets_to_end : String gets_to_end, peek : Bytes? peek, print(*objects : _) : Nil
print(obj) : Nil print
, printf(format_string, args : Array | Tuple) : Nil
printf(format_string, *args) : Nil printf
, puts(*objects : _) : Nil
puts : Nil
puts(obj) : Nil
puts(string : String) : Nil puts
, read(slice : Bytes) read, read_byte : UInt8? read_byte, read_bytes(type, format : IO::ByteFormat = IO::ByteFormat::SystemEndian) read_bytes, read_char : Char? read_char, read_fully(slice : Bytes) read_fully, read_fully?(slice : Bytes) read_fully?, read_line(*args, **options) : String? read_line, read_string(bytesize : Int) : String read_string, read_utf8(slice : Bytes) read_utf8, read_utf8_byte read_utf8_byte, rewind rewind, set_encoding(encoding : String, invalid : Symbol? = nil) set_encoding, skip(bytes_count : Int) : Nil skip, skip_to_end : Nil skip_to_end, tty? : Bool tty?, write(slice : Bytes) : Nil write, write_byte(byte : UInt8) write_byte, write_bytes(object, format : IO::ByteFormat = IO::ByteFormat::SystemEndian) write_bytes, write_utf8(slice : Bytes) write_utf8

Class methods inherited from module IO

copy(src, dst, limit : Int)
copy(src, dst) copy
, pipe(read_blocking = false, write_blocking = false)
pipe(read_blocking = false, write_blocking = false, &block) pipe
, select(read_ios, write_ios, error_ios, timeout_sec : LibC::TimeT | Int | Float?)
select(read_ios, write_ios = nil, error_ios = nil) select

Instance Method Detail

def close : NilSource

Flushes and closes the underlying IO.

def flushSource

Flushes any buffered data and the underlying IO. Returns self.

def flush_on_newline=(flush_on_newline)Source

Turns on/off flushing the underlying IO when a newline is written.

def flush_on_newline?Source

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)Source

Buffered implementation of IO#read(slice).

def rewindSource

Rewinds the underlying IO. Returns self.

def sync=(sync)Source

Turns on/off IO 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).

def sync?Source

Determines if this IO does buffering. If true, no buffering is done.

abstract def unbuffered_closeSource

Closes the wrapped IO.

abstract def unbuffered_flushSource

Flushes the wrapped IO.

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_rewindSource

Rewinds the wrapped IO.

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)Source

Buffered implementation of IO#write(slice).

© 2012–2017 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.22.0/IO/Buffered.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部