@@ -200,16 +200,31 @@ pub const UnpackReader = struct {
200200 return self .unpack .int (Int , header );
201201 }
202202
203- /// Create reader for the value's raw data. This function can be used on
204- /// any value that have determined byte size in the header. The arrays and
205- /// the maps could not be read use this function.
203+ /// Create a reader for the value's raw data.
204+ ///
205+ /// This function can be used on any value that have determined
206+ /// byte size in the header. The arrays and the maps could not be
207+ /// read with this function.
208+ /// To skip arrays and maps, see `skip`.
206209 ///
207210 /// Errors:
208211 /// - `ConvertError.InvalidValue` - the value could not be
209212 /// converted to this host type
213+ ///
214+ /// ```zig
215+ /// var unpacker: *UnpackReader;
216+ /// const reader: std.io.AnyReader;
217+ /// var buf: std.ArrayList(u8);
218+ ///
219+ /// const head = try unpacker.next(reader);
220+ /// var rawReader = try unpacker.rawReader(reader, head);
221+ ///
222+ /// try rawReader.reader().readAllArrayList(&buf, 4096);
223+ /// ```
210224 pub fn rawReader (self : * UnpackReader , reader : anytype , header : fmt.Header ) ! RawReader (@TypeOf (reader )) {
211- if (header .type == .map or header .type == .array ) {
212- return fmt .Unpack .ConvertError .InvalidValue ;
225+ switch (header .type ) {
226+ .map , .array , .fixmap , .fixarray = > return ConvertError .InvalidValue ,
227+ else = > {},
213228 }
214229
215230 const prefixSize = @min (self .unpack .rest .len , header .size );
0 commit comments