tiny.peer.Relay
Defined in tiny.peer.
API (8)
Actions
Public operations.
Types and contracts
Public types and contracts.
Fields and members
Public fields and members.
Source
Source: lib/peer/src/address.zig:34
zig
pub const Relay = struct { bytes: [relay_host_bytes_max]u8, len: u8, port: u16, pub const InitError: type = RelayInitError; pub fn init(host_name: []const u8, port: u16) InitError!Relay { if (host_name.len == 0) return error.HostEmpty; if (host_name.len > relay_host_bytes_max) return error.HostTooLong; for (host_name) |byte| { if (!hostByteValid(byte)) return error.InvalidHost; } var result = Relay{ .bytes = @splat(0), .len = @intCast(host_name.len), .port = port, }; @memcpy(result.bytes[0..host_name.len], host_name); return result; } pub fn host(self: *const Relay) []const u8 { std.debug.assert(self.len <= relay_host_bytes_max); return self.bytes[0..self.len]; } pub fn valid(self: *const Relay) bool { if (self.len == 0 or self.len > relay_host_bytes_max) return false; for (self.bytes[0..self.len]) |byte| { if (!hostByteValid(byte)) return false; } return true; } pub fn eql(self: *const Relay, other: *const Relay) bool { return self.port == other.port and std.mem.eql(u8, self.host(), other.host()); }};Source: lib/peer/src/root.zig:23
zig
pub const Relay = address.Relay;Audit
| Definitions | 6 |
|---|---|
| Public names | 6 |
| Members | 3 |
| Version | 26.7.0 |
| Revision | daab053ee433 |