Protocol::CassandraCQL::Frame
- a byte buffer storing the content of a CQL message frame
This class provides wire-protocol encoding and decoding support for constructing and parsing Cassandra CQL message frames. An object represents a buffer during construction or parsing.
To construct a message frame,
create a new empty object and use the pack_*
methods to append data to it,
before eventually obtaining the actual frame bytes using bytes
.
Each pack_*
method returns the frame object,
allowing them to be easily chained:
my $bytes = Protocol::CassandraCQL::Frame->new ->pack_short( 123 ) ->pack_int( 45678 ) ->pack_string( "here is the data" ) ->bytes;
To parse a message frame, create a new object from the bytes in the message, and use the unpack_*
methods to consume the values from it.
my $frame = Protocol::CassandraCQL::Frame->new( $bytes ); my $s = $frame->unpack_short; my $i = $frame->unpack_int; my $str = $frame->unpack_string;
Returns a new frame buffer, optionally initialised with the given byte string.
Returns the byte string currently in the buffer.
Add or remove a byte value.
Add or remove a short value.
Add or remove an int value.
Add or remove a string value.
Add or remove a long string value.
Add or remove a UUID as a plain 16-byte raw scalar
Add or remove a list of strings from or to an ARRAYref
Add or remove opaque bytes or undef
.
Add or remove opaque short bytes.
Add or remove an IPv4 or IPv6 address from or to a packed sockaddr string (such as returned from pack_sockaddr_in
or pack_sockaddr_in6
.
Add or remove a string map from or to a HASH of strings.
Add or remove a string multimap from or to a HASH of ARRAYs of strings.
This code was paid for by
Paul Evans <leonerd@leonerd.org.uk>