From ccb25adfd97f4ba65125e3b4dd40e2b82cdd7a39 Mon Sep 17 00:00:00 2001 From: JJ Merelo Date: Sun, 7 Apr 2019 08:38:21 +0200 Subject: [PATCH] Revises Buf for #2709, minor changes Also adds missing methods for Blob. Refs #2694. --- doc/Type/Blob.pod6 | 29 +++++++++++++++++++++++++++-- doc/Type/Buf.pod6 | 4 ++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/doc/Type/Blob.pod6 b/doc/Type/Blob.pod6 index c8e996a69..fe8b46878 100644 --- a/doc/Type/Blob.pod6 +++ b/doc/Type/Blob.pod6 @@ -76,6 +76,31 @@ 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 with C as payload. + +=head2 method Str + +Defined as: + + multi method Str(Blob:D:) + +Throws C with C as payload. In order to convert to a C +you need to use L|/routine/decode>. + +=head2 method Stringy + +Defined as: + + multi method Stringy(Blob:D:) + +Throws C with C as payload. + =head2 method decode Defined as: @@ -83,8 +108,8 @@ 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) diff --git a/doc/Type/Buf.pod6 b/doc/Type/Buf.pod6 index 9ce771e22..aba013669 100644 --- a/doc/Type/Buf.pod6 +++ b/doc/Type/Buf.pod6 @@ -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 is a mutable sequence of (usually unsigned) integers. +A C does the role of a mutable sequence of (usually unsigned) integers. my $b = Buf.new(1, 2, 3); $b[1] = 42;