|
7 | 7 | //! |
8 | 8 | //! - `Unpack.peek` begins the unpack process for a value. |
9 | 9 | //! - The function returns a `HeaderType`. |
10 | | -//! - Use `HeaderType.nextComponentSize` to get the required data size |
| 10 | +//! - Use `HeaderType.countData` to get the required data size |
11 | 11 | //! for the header. |
12 | 12 | //! - Ensured the `Unpack.rest` have enough data, use `Unpack.next` move to |
13 | 13 | //! the next value and extract the header. |
|
35 | 35 | //! const unpack: Unpack = Unpack.init(data); |
36 | 36 | //! |
37 | 37 | //! if (unpack.peek()) |peek| { |
38 | | -//! const requiredSize = peek.nextComponentSize(); |
| 38 | +//! const requiredSize = peek.count(); |
39 | 39 | //! if (requiredSize > unpack.rest.len) { |
40 | 40 | //! const ndata = readMore(data); |
41 | 41 | //! unpack.setAppend(data.len, ndata); |
@@ -96,11 +96,11 @@ pub fn peek(self: *const Unpack) PeekError!HeaderType { |
96 | 96 | /// this is also the number of bytes of container types. |
97 | 97 | /// |
98 | 98 | /// Calling this function, you must confirm the buffer has enough data to |
99 | | -/// read. Use `HeaderType.nextComponentSize` to get the expected size for |
| 99 | +/// read. Use `HeaderType.count` to get the expected size for |
100 | 100 | /// the value header. |
101 | 101 | pub fn next(self: *Unpack, headerType: HeaderType) Header { |
102 | | - const header, const consumes = Header.from(headerType, self.rest[1..]); |
103 | | - self.rest = self.rest[1 + consumes ..]; |
| 102 | + const header = Header.from(headerType, self.rest[1..]); |
| 103 | + self.rest = self.rest[headerType.count()..]; |
104 | 104 | return header; |
105 | 105 | } |
106 | 106 |
|
|
0 commit comments