Skip to content

Commit 0984441

Browse files
committed
remove HeaderType.nextComponentSize
1 parent e623c56 commit 0984441

File tree

3 files changed

+123
-165
lines changed

3 files changed

+123
-165
lines changed

src/Unpack.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//!
88
//! - `Unpack.peek` begins the unpack process for a value.
99
//! - 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
1111
//! for the header.
1212
//! - Ensured the `Unpack.rest` have enough data, use `Unpack.next` move to
1313
//! the next value and extract the header.
@@ -35,7 +35,7 @@
3535
//! const unpack: Unpack = Unpack.init(data);
3636
//!
3737
//! if (unpack.peek()) |peek| {
38-
//! const requiredSize = peek.nextComponentSize();
38+
//! const requiredSize = peek.count();
3939
//! if (requiredSize > unpack.rest.len) {
4040
//! const ndata = readMore(data);
4141
//! unpack.setAppend(data.len, ndata);
@@ -96,11 +96,11 @@ pub fn peek(self: *const Unpack) PeekError!HeaderType {
9696
/// this is also the number of bytes of container types.
9797
///
9898
/// 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
100100
/// the value header.
101101
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()..];
104104
return header;
105105
}
106106

src/io.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub const UnpackReader = struct {
172172
/// Return `error.EndOfStream` if the stream is ended.
173173
pub fn next(self: *UnpackReader, reader: anytype) !fmt.Header {
174174
const htyp = try self.peek(reader);
175-
if (htyp.nextComponentSize() > self.unpack.rest.len) {
175+
if (htyp.count() > self.unpack.rest.len) {
176176
try self.readMore(reader);
177177
}
178178
return self.unpack.next(htyp);

0 commit comments

Comments
 (0)