File Coverage

blib/lib/Thrift/XS/MemoryBuffer.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Thrift::XS::MemoryBuffer;
2              
3 4     4   35 use strict;
  4         11  
  4         228  
4 4     4   25 use base('Thrift::Transport');
  4         7  
  4         2208  
5              
6 4     4   42761 use Thrift::XS;
  4         8  
  4         132  
7              
8             # Implementation is in MemoryBuffer.xs
9              
10             1;
11             __END__
12              
13             =head1 NAME
14              
15             Thrift::XS::MemoryBuffer - Fast memory buffer
16              
17             =head1 SYNOPSIS
18              
19             use Thrift;
20             use Thrift::XS::MemoryBuffer;
21             use Thrift::XS::CompactProtocol;
22             use MyThriftInterface;
23            
24             my $transport = Thrift::XS::MemoryBuffer->new(8192);
25             my $protocol = Thrift::XS::BinaryProtocol->new($transport);
26             my $client = MyThriftInterface->new($protocol);
27            
28             $transport->open;
29            
30             $client->api_call( @args );
31              
32             =head1 DESCRIPTION
33              
34             This module is useful when writing your own socket-layer implementation, for example,
35             it is used with L<AnyEvent::Cassandra>.
36              
37             =head1 METHODS
38              
39             =head2 new( [ BUFFER_SIZE ] )
40              
41             Create a new buffer instance. Default buffer size is 8192 bytes.
42              
43             =head2 available()
44              
45             Return the amount of bytes waiting to be read from the buffer.
46              
47             =head2 read( LENGTH )
48              
49             Try to read LENGTH bytes from the buffer. If less bytes are available, as many as
50             possible will be returned.
51              
52             =head2 readAll( LENGTH )
53              
54             Similar to read, but dies if LENGTH bytes are not available.
55              
56             =head2 write( DATA, [ LENGTH ] )
57              
58             Append DATA to the buffer. LENGTH is optional but if provided it will avoid making
59             a length function call.
60              
61             =head1 AUTHOR
62              
63             Andy Grundman, E<lt>andy@slimdevices.comE<gt>
64              
65             =head1 COPYRIGHT AND LICENSE
66              
67             Copyright 2011 Logitech, Inc.
68              
69             Licensed under the Apache License, Version 2.0 (the "License");
70             you may not use this file except in compliance with the License.
71             You may obtain a copy of the License at
72              
73             http://www.apache.org/licenses/LICENSE-2.0
74              
75             Unless required by applicable law or agreed to in writing, software
76             distributed under the License is distributed on an "AS IS" BASIS,
77             WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
78             See the License for the specific language governing permissions and
79             limitations under the License.
80              
81             =cut