File Coverage

lib/SIRTX/VM/Chunk/Type/Padding.pm
Criterion Covered Total %
statement 14 23 60.8
branch 0 4 0.0
condition n/a
subroutine 5 9 55.5
pod 1 1 100.0
total 20 37 54.0


line stmt bran cond sub pod time code
1             # Copyright (c) 2025 Philipp Schafft
2              
3             # licensed under Artistic License 2.0 (see LICENSE file)
4              
5             # ABSTRACT: module for interacting with SIRTX VM chunks
6              
7              
8             package SIRTX::VM::Chunk::Type::Padding;
9              
10 1     1   1289 use v5.16;
  1         4  
11 1     1   7 use strict;
  1         2  
  1         29  
12 1     1   5 use warnings;
  1         3  
  1         61  
13              
14 1     1   7 use Carp;
  1         3  
  1         88  
15              
16 1     1   7 use parent 'SIRTX::VM::Chunk::Type';
  1         2  
  1         8  
17              
18             our $VERSION = v0.03;
19              
20              
21             sub data_size {
22 0     0 1   my ($self, $n, @opts) = @_;
23              
24 0 0         croak 'Stray options passed' if scalar @opts;
25              
26 0 0         if (defined $n) {
27 0           my $str = chr(0) x $n;
28 0           open(my $fh, '<:raw', \$str);
29 0           $self->SIRTX::VM::Chunk::attach_data($fh);
30             }
31              
32 0           return $self->_data_length;
33             }
34              
35             # ---- Private helpers ----
36              
37             sub _create_data {
38 0     0     my ($self) = @_;
39 0           $self->data_size(0);
40             }
41              
42       0     sub _parse {
43             # no-op
44             }
45              
46       0     sub _render {
47             # no-op
48             }
49              
50             1;
51              
52             __END__
53              
54             =pod
55              
56             =encoding UTF-8
57              
58             =head1 NAME
59              
60             SIRTX::VM::Chunk::Type::Padding - module for interacting with SIRTX VM chunks
61              
62             =head1 VERSION
63              
64             version v0.03
65              
66             =head1 SYNOPSIS
67              
68             use SIRTX::VM::Chunk::Type::Padding;
69              
70             my SIRTX::VM::Chunk $chunk = SIRTX::VM::Chunk::Type::Padding->new;
71              
72             $chunk->data_size($size);
73              
74             (since v0.02)
75              
76             This represends a padding chunk.
77              
78             This inherits from L<SIRTX::VM::Chunk>.
79              
80             =head2 data_size
81              
82             my $size = $chunk->data_size;
83             # or:
84             $chunk->data_size($size);
85              
86             Sets the (data size) of the padding chunk.
87              
88             B<Note:>
89             The actual size of the chunk will be larger than this value due to it's header and framing considerations.
90              
91             =head1 AUTHOR
92              
93             Philipp Schafft <lion@cpan.org>
94              
95             =head1 COPYRIGHT AND LICENSE
96              
97             This software is Copyright (c) 2025 by Philipp Schafft <lion@cpan.org>.
98              
99             This is free software, licensed under:
100              
101             The Artistic License 2.0 (GPL Compatible)
102              
103             =cut