UV/Handle/Stream.pm untested

filter: Statementstmt n/a Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a SCAR -
1 package SPVM::UV::Handle::Stream;
2  
3  
4  
5 1;
6  
7 =encoding utf8
8  
9 =head1 Name
10  
11 SPVM::UV::Handle::Stream - Stream Handle for libuv
12  
13 =head1 Description
14  
15 C<UV::Handle::Stream> in L<SPVM> represents the stream handle for L<libuv|https://libuv.org/>, corresponding to the C<uv_stream_t> structure.
16  
17 =head1 Super Class
18  
19 L<UV::Handle|SPVM::UV::Handle>
20  
21 =head1 Usage
22  
23 use UV::Handle::Stream;
24  
25 =head1 Fields
26  
27 =head2 read_cb
28  
29 C<has read_cb : rw L<UV::Callback::Read|SPVM::UV::Callback::Read>;>
30  
31 The callback called when data has been read from the stream.
32  
33 =head2 read_buffer
34  
35 C<has read_buffer : rw mutable string;>
36  
37 The buffer associated with the read operation.
38  
39 =head2 read_buffer_length
40  
41 C<has read_buffer_length : rw int;>
42  
43 The length of the read buffer.
44  
45 =head2 read_buffer_offset
46  
47 C<has read_buffer_offset : rw int;>
48  
49 The offset of the read buffer.
50  
51 =head1 Instance Methods
52  
53 =head2 read_start
54  
55 C<method read_start : void ($buffer : mutable string, $buffer_length : int, $cb : L<UV::Callback::Read|SPVM::UV::Callback::Read>, $buffer_offset : int = 0);>
56  
57 Starts reading data into C<$buffer> with length C<$buffer_length> and offset C<$buffer_offset> from the stream.
58  
59 The callback C<$cb> is stored in L</"read_cb"> field. The buffer C<$buffer> is stored in L</"read_buffer"> field. The length C<$buffer_length> is stored in L</"read_buffer_length"> field. The offset C<$buffer_offset> is stored in L</"read_buffer_offset"> field.
60  
61 The callback C<$cb> is invoked when data has been read from the stream.
62  
63 This method calls the L<uv_read_start|https://docs.libuv.org/en/v1.x/stream.html#c.uv_read_start> function internally.
64  
65 Exceptions:
66  
67 If $buffer is not defined, an exception is thrown.
68  
69 If $buffer_length is not a positive number, an exception is thrown.
70  
71 If $buffer_offset + $buffer_length is greater than the length of C<$buffer>, an exception is thrown.
72  
73 If $cb is not defined, an exception is thrown.
74  
75 If uv_read_start> fails, an exception is thrown.
76  
77 =head2 read_stop
78  
79 C<method read_stop : void ();>
80  
81 Stops reading data from the stream.
82  
83 This method calls the L<uv_read_stop|https://docs.libuv.org/en/v1.x/stream.html#c.uv_read_stop> function internally.
84  
85 Exceptions:
86  
87 If uv_read_stop fails, an exception is thrown.
88  
89 =head1 Copyright & License
90  
91 Copyright (c) 2026 Yuki Kimoto
92  
93 MIT License