A Buffer represents a sequence of zero or more bytes that can be
written to or read from, and which expands as necessary to accomodate any
bytes written to it.
Buffers are used in many places in vert.x, for example to read/write
data to/from NetSocket, AsyncFile, WebSocket, HttpClientRequest,
HttpClientResponse, HttpServerRequest, HttpServerResponse etc.
There are two ways to write data to a Buffer: The first method
involves methods that take the form set_XXX. These methods write data
into the buffer starting at the specified position. The position does not
have to be inside data that has already been written to the buffer; the
buffer will automatically expand to encompass the position plus any data
that needs to be written. All positions are measured in bytes and start
with zero.
The second method involves methods that take the form append-XXX;
these methods append data at the end of the buffer. Methods exist to both
set and append all primitive types, String and other instances of
Buffer.
Data can be read from a buffer by invoking methods which take the form
get_XXX. These methods take a parameter representing the position in the
Buffer from where to read data.
|
|
|
|
|
to_string(self,
enc="UTF-8")
Buffer in enc encoding |
source code
|
|
|
get_byte(self,
pos)
Get the byte at position pos in the buffer. |
source code
|
|
|
get_fixnum(self,
pos,
bytes)
Get the fixnum represented by a sequence of bytes starting at
position pos in the buffer. |
source code
|
|
|
get_float(self,
pos,
bytes)
Get the float represented by a sequence of bytes starting at position
pos in the buffer. |
source code
|
|
|
get_string(self,
pos,
end_pos,
enc='UTF-8')
Return bytes from the buffer interpreted as a String |
source code
|
|
|
get_buffer(self,
pos,
end_pos)
Return bytes in the buffer as a Buffer |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
set_float(self,
pos,
num,
bytes)
Sets bytes in the buffer to a representation of a float. |
source code
|
|
|
|
|
set_string(self,
pos,
str,
enc="UTF-8")
Set bytes in the buffer to the string encoding in the specified
encoding |
source code
|
|
|
|
|
copy(self)
Get a copy of the entire buffer. |
source code
|
|
|
|