Skip to content

Commit ccb25ad

Browse files
committed
Revises Buf for #2709, minor changes
Also adds missing methods for Blob. Refs #2694.
1 parent 06c05be commit ccb25ad

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

doc/Type/Blob.pod6

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,40 @@ Returns the number of bytes used by the elements in the buffer.
7676
say blob16.new([1, 2, 3]).bytes; # OUTPUT: «6␤»
7777
say blob64.new([1, 2, 3]).bytes; # OUTPUT: «24␤»
7878
79+
=head2 method chars
80+
81+
Defined as:
82+
83+
method chars(Blob:D:)
84+
85+
Throws C<X::Buf::AsStr> with C<chars> as payload.
86+
87+
=head2 method Str
88+
89+
Defined as:
90+
91+
multi method Str(Blob:D:)
92+
93+
Throws C<X::Buf::AsStr> with C<Str> as payload. In order to convert to a C<Str>
94+
you need to use L<C<.decode>|/routine/decode>.
95+
96+
=head2 method Stringy
97+
98+
Defined as:
99+
100+
multi method Stringy(Blob:D:)
101+
102+
Throws C<X::Buf::AsStr> with C<Stringy> as payload.
103+
79104
=head2 method decode
80105
81106
Defined as:
82107
83108
multi method decode(Blob:D: $encoding = self.encoding // "utf-8")
84109
85110
=for code :method
86-
multi method decode(Blob:D: $encoding, Str :$replacement!,
87-
Bool:D :$strict = False)
111+
multi method decode(Blob:D: $encoding, Str :$replacement!,
112+
Bool:D :$strict = False)
88113
89114
multi method decode(Blob:D: $encoding, Bool:D :$strict = False)
90115

doc/Type/Buf.pod6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
55
=SUBTITLE Mutable buffer for binary data
66
7-
role Buf[::T] does Blob[T] { ... }
7+
role Buf[::T = uint8] does Blob[T] is repr('VMArray') is array_type(T){ ... }
88
9-
A C<Buf> is a mutable sequence of (usually unsigned) integers.
9+
A C<Buf> does the role of a mutable sequence of (usually unsigned) integers.
1010
1111
my $b = Buf.new(1, 2, 3);
1212
$b[1] = 42;

0 commit comments

Comments
 (0)