Skip to content

Commit

Permalink
Revises Buf for #2709, minor changes
Browse files Browse the repository at this point in the history
Also adds missing methods for Blob. Refs #2694.
  • Loading branch information
JJ committed Apr 7, 2019
1 parent 06c05be commit ccb25ad
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
29 changes: 27 additions & 2 deletions doc/Type/Blob.pod6
Expand Up @@ -76,15 +76,40 @@ Returns the number of bytes used by the elements in the buffer.
say blob16.new([1, 2, 3]).bytes; # OUTPUT: «6␤»
say blob64.new([1, 2, 3]).bytes; # OUTPUT: «24␤»
=head2 method chars
Defined as:
method chars(Blob:D:)
Throws C<X::Buf::AsStr> with C<chars> as payload.
=head2 method Str
Defined as:
multi method Str(Blob:D:)
Throws C<X::Buf::AsStr> with C<Str> as payload. In order to convert to a C<Str>
you need to use L<C<.decode>|/routine/decode>.
=head2 method Stringy
Defined as:
multi method Stringy(Blob:D:)
Throws C<X::Buf::AsStr> with C<Stringy> as payload.
=head2 method decode
Defined as:
multi method decode(Blob:D: $encoding = self.encoding // "utf-8")
=for code :method
multi method decode(Blob:D: $encoding, Str :$replacement!,
Bool:D :$strict = False)
multi method decode(Blob:D: $encoding, Str :$replacement!,
Bool:D :$strict = False)
multi method decode(Blob:D: $encoding, Bool:D :$strict = False)
Expand Down
4 changes: 2 additions & 2 deletions doc/Type/Buf.pod6
Expand Up @@ -4,9 +4,9 @@
=SUBTITLE Mutable buffer for binary data
role Buf[::T] does Blob[T] { ... }
role Buf[::T = uint8] does Blob[T] is repr('VMArray') is array_type(T){ ... }
A C<Buf> is a mutable sequence of (usually unsigned) integers.
A C<Buf> does the role of a mutable sequence of (usually unsigned) integers.
my $b = Buf.new(1, 2, 3);
$b[1] = 42;
Expand Down

0 comments on commit ccb25ad

Please sign in to comment.