Class: Thrift::BaseTransport
- Inherits:
-
Object
- Object
- Thrift::BaseTransport
- Defined in:
- lib/thrift/transport/base_transport.rb
Direct Known Subclasses
BufferedTransport, FramedTransport, HTTPClientTransport, IOStreamTransport, MemoryBufferTransport, Socket
Instance Method Summary collapse
- #close ⇒ Object
- #flush ⇒ Object
- #open ⇒ Object
- #open? ⇒ Boolean
-
#read(sz) ⇒ Object
Reads a number of bytes from the transports.
- #read_all(size) ⇒ Object
-
#read_byte ⇒ Object
Returns an unsigned byte as a Fixnum in the range (0..255).
-
#read_into_buffer(buffer, size) ⇒ Object
Reads size bytes and copies them into buffer.
- #set_context(ctx) ⇒ Object
-
#write(buf) ⇒ Object
(also: #<<)
Writes the byte buffer to the transport.
Instance Method Details
#close ⇒ Object
54 |
# File 'lib/thrift/transport/base_transport.rb', line 54 def close; end |
#flush ⇒ Object
103 |
# File 'lib/thrift/transport/base_transport.rb', line 103 def flush; end |
#open ⇒ Object
52 |
# File 'lib/thrift/transport/base_transport.rb', line 52 def open; end |
#open? ⇒ Boolean
50 |
# File 'lib/thrift/transport/base_transport.rb', line 50 def open?; end |
#read(sz) ⇒ Object
Reads a number of bytes from the transports. In Ruby 1.9+, the String returned will have a BINARY (aka ASCII8BIT) encoding.
sz - The number of bytes to read from the transport.
Returns a String acting as a byte buffer.
61 62 63 |
# File 'lib/thrift/transport/base_transport.rb', line 61 def read(sz) raise NotImplementedError end |
#read_all(size) ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/thrift/transport/base_transport.rb', line 84 def read_all(size) return Bytes.empty_byte_buffer if size <= 0 buf = read(size) while (buf.length < size) chunk = read(size - buf.length) buf << chunk end buf end |
#read_byte ⇒ Object
Returns an unsigned byte as a Fixnum in the range (0..255).
68 69 70 71 |
# File 'lib/thrift/transport/base_transport.rb', line 68 def read_byte buf = read_all(1) return Bytes.get_string_byte(buf, 0) end |
#read_into_buffer(buffer, size) ⇒ Object
Reads size bytes and copies them into buffer.
74 75 76 77 78 79 80 81 82 |
# File 'lib/thrift/transport/base_transport.rb', line 74 def read_into_buffer(buffer, size) tmp = read_all(size) i = 0 tmp.each_byte do |byte| Bytes.set_string_byte(buffer, i, byte) i += 1 end i end |
#set_context(ctx) ⇒ Object
65 |
# File 'lib/thrift/transport/base_transport.rb', line 65 def set_context(ctx); end |
#write(buf) ⇒ Object Also known as: <<
Writes the byte buffer to the transport. In Ruby 1.9+, the buffer will be forced into BINARY encoding.
buf - A String acting as a byte buffer.
Returns nothing.
100 |
# File 'lib/thrift/transport/base_transport.rb', line 100 def write(buf); end |