tiny.peer.decode
Defined in tiny.peer.
Source
Source: lib/peer/src/ticket.zig:339
zig
pub fn decode( source: []const u8, storage: Ticket.Storage, limits: Limits,) DecodeError!Ticket { var address_storage = TicketStorage.init(storage, limits) catch |err| switch (err) { error.CapacityOverflow => return error.InvalidLimits, error.StorageTooShort => return error.StorageTooShort, }; address_storage.activate(); errdefer _ = address_storage.deinit(); var cursor = Cursor{ .source = source }; const actual_magic = try cursor.take(magic.len); if (!std.mem.eql(u8, actual_magic, &magic)) return error.WrongMagic; if (try cursor.byte() != version) return error.UnknownVersion; const peer = PeerId{ .key = (try cursor.take(identity.key_bytes))[0..identity.key_bytes].* }; const count = try cursor.byte(); if (count > address_storage.capacity.max_addresses) return error.TooManyAddresses; var ticket = Ticket{ .peer = peer, .address_storage = address_storage, }; for (0..address_count_max) |index| { if (index >= count) break; ticket.append(try decodeAddress(&cursor)) catch return error.TooManyAddresses; } if (cursor.index != source.len) return error.TrailingBytes; return ticket;}Source: lib/peer/src/root.zig:35
zig
pub const decode = ticket.decode;Audit
| Definitions | 1 |
|---|---|
| Public names | 1 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |