BaseTransport
# File lib/thrift/transport/framed_transport.rb, line 39 def close @transport.close end
Writes the output buffer to the stream in the format of a 4-byte length followed by the actual data.
# File lib/thrift/transport/framed_transport.rb, line 90 def flush return @transport.flush unless @write out = [@wbuf.length].pack('N') # Array#pack should return a BINARY encoded String, so it shouldn't be necessary to force encoding out << @wbuf @transport.write(out) @transport.flush @wbuf = Bytes.empty_byte_buffer end
# File lib/thrift/transport/framed_transport.rb, line 35 def open @transport.open end
# File lib/thrift/transport/framed_transport.rb, line 31 def open? @transport.open? end
# File lib/thrift/transport/framed_transport.rb, line 43 def read(sz) return @transport.read(sz) unless @read return Bytes.empty_byte_buffer if sz <= 0 read_frame if @index >= @rbuf.length @index += sz @rbuf.slice(@index - sz, sz) || Bytes.empty_byte_buffer end
# File lib/thrift/transport/framed_transport.rb, line 54 def read_byte return @transport.read_byte() unless @read read_frame if @index >= @rbuf.length # The read buffer has some data now, read a single byte. Using get_string_byte() avoids # allocating a temp string of size 1 unnecessarily. @index += 1 return Bytes.get_string_byte(@rbuf, @index - 1) end
# File lib/thrift/transport/framed_transport.rb, line 65 def read_into_buffer(buffer, size) i = 0 while i < size read_frame if @index >= @rbuf.length # The read buffer has some data now, so copy bytes over to the output buffer. byte = Bytes.get_string_byte(@rbuf, @index) Bytes.set_string_byte(buffer, i, byte) @index += 1 i += 1 end i end
Generated with the Darkfish Rdoc Generator 2.