class NGHTTP::TransparentIO

Defined in:

nghttp/io/transparent_io.cr

Constructors

Instance Method Summary

Instance methods inherited from class IO

pack(spec, *a) pack, reunpack(src, dst, *vars) reunpack, unpack(spec) unpack

Constructor Detail

def self.new(io : IO, close_underlying_io : Bool = true) #

[View source]

Instance Method Detail

def close #
Description copied from class IO

Closes this IO.

IO defines this is a no-op method, but including types may override.


[View source]
def close_underlying_io : Bool #

[View source]
def close_underlying_io=(close_underlying_io : Bool) #

[View source]
def debug_hex #

[View source]
def flush #
Description copied from class IO

Flushes buffered data, if any.

IO defines this is a no-op method, but including types may override.


[View source]
def io : IO #

[View source]
def io=(io : IO) #

[View source]
def on_close(&b : Closer) #

[View source]
def on_close=(v : Nil) #

[View source]
def on_read(&b : Bytes, Int32 | Int64 -> ) #

[View source]
def on_read=(v : Nil) #

[View source]
def on_write(&b : Bytes -> ) #

[View source]
def on_write=(v : Nil) #

[View source]
def peek #
Description copied from class IO

Peeks into this IO, if possible.

It returns:

  • nil if this IO isn't peekable at this moment or at all
  • an empty slice if it is, but EOF was reached
  • a non-empty slice if some data can be peeked

The returned bytes are only valid data until a next call to any method that reads from this IO is invoked.

By default this method returns nil, but IO implementations that provide buffering or wrap other IOs should override this method.


[View source]
def read(slice : Bytes) #
Description copied from class IO

Reads at most slice.size bytes from this IO into slice. Returns the number of bytes read, which is 0 if and only if there is no more data to read (so checking for 0 is the way to detect end of file).

io = IO::Memory.new "hello"
slice = Bytes.new(4)
io.read(slice) # => 4
slice          # => Bytes[104, 101, 108, 108]
io.read(slice) # => 1
slice          # => Bytes[111, 101, 108, 108]
io.read(slice) # => 0

[View source]
def rewind #
Description copied from class IO

Rewinds this IO. By default this method raises, but including types may implement it.


[View source]
def to_s(io : IO) #
Description copied from class Reference

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>

[View source]
def to_s #
Description copied from class Object

Returns a nicely readable and concise string representation of this object, typically intended for users.

This method should usually not be overridden. It delegates to #to_s(IO) which can be overridden for custom implementations.

Also see #inspect.


[View source]
def wait_readable(t) #

[View source]
def write(slice : Bytes) : Nil #
Description copied from class IO

Writes the contents of slice into this IO.

io = IO::Memory.new
slice = Bytes.new(4) { |i| ('a'.ord + i).to_u8 }
io.write(slice)
io.to_s # => "abcd"

[View source]