class Thrift::BaseTransport
Public Instance Methods
Source
# File lib/thrift/transport/base_transport.rb 60 def message_boundaries? 61 false 62 end
Returns true when the transport needs protocol message boundary notifications.
Source
# File lib/thrift/transport/base_transport.rb 69 def read(sz) 70 raise NotImplementedError 71 end
Reads a number of bytes from the transports. The String returned will have a BINARY (aka ASCII-8BIT) encoding.
sz - The number of bytes to read from the transport.
Returns a String acting as a byte buffer.
Source
# File lib/thrift/transport/base_transport.rb 90 def read_all(size) 91 raise TransportException.new(TransportException::NEGATIVE_SIZE, "Negative size") unless size >= 0 92 return Bytes.empty_byte_buffer if size == 0 93 94 buf = read(size) 95 if buf.nil? || buf.empty? 96 raise TransportException.new(TransportException::END_OF_FILE, "No more data available") 97 end 98 99 buf = Bytes.force_binary_encoding(buf) 100 return buf if buf.length >= size 101 102 buf = buf.dup if buf.frozen? 103 while (buf.length < size) 104 chunk = read(size - buf.length) 105 if chunk.nil? || chunk.empty? 106 raise TransportException.new(TransportException::END_OF_FILE, "No more data available") 107 end 108 109 buf << Bytes.force_binary_encoding(chunk) 110 end 111 112 buf 113 end
Source
# File lib/thrift/transport/base_transport.rb 74 def read_byte 75 buf = read_all(1) 76 Bytes.get_string_byte(buf, 0) 77 end
Returns an unsigned byte as a Integer in the range (0..255).
Source
# File lib/thrift/transport/base_transport.rb 80 def read_into_buffer(buffer, size) 81 tmp = read_all(size) 82 i = 0 83 tmp.each_byte do |byte| 84 Bytes.set_string_byte(buffer, i, byte) 85 i += 1 86 end 87 i 88 end
Reads size bytes and copies them into buffer.
Source
# File lib/thrift/transport/base_transport.rb 120 def write(buf); end
Writes the byte buffer to the transport. The buffer will be forced into BINARY encoding.
buf - A String acting as a byte buffer.
Returns nothing.
Also aliased as: <<