authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-07-08 03:28:46 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-07-08 03:28:46 -07:00
logb4fd3a83d489d1ffe981733ed9b43746c0d64165
treeb1ebd1b30ef1e0855fe88e682a5fbda751a42671
parentb9d04a0ae1c54938c7967cda2340d2e6c95495b3
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

Address: format -> nprint


1 files changed, 8 insertions(+), 11 deletions(-)

net.zig+8-11
......@@ -49,10 +49,10 @@ pub const Address = extern union {
4949 };
5050 }
5151
52 pub fn format(adr: Address, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
52 pub fn nprint(adr: Address, writer: anytype) !void {
5353 switch (adr.any.family) {
54 .INET => try adr.in.format(fmt, options, writer),
55 .INET6 => try adr.in6.format(fmt, options, writer),
54 .INET => try adr.in.nprint(writer),
55 .INET6 => try adr.in6.nprint(writer),
5656 else => |a| try writer.print("{{any:{s}}}", .{@tagName(a)}),
5757 }
5858 }
......@@ -132,9 +132,7 @@ pub const Ip4Address = extern struct {
132132 };
133133 }
134134
135 pub fn format(adr: Ip4Address, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
136 _ = fmt;
137 _ = options;
135 pub fn nprint(adr: Ip4Address, writer: anytype) !void {
138136 const parts: [4]u8 = @bitCast(adr.sa.addr.addr);
139137 const port = @byteSwap(adr.sa.port);
140138 try writer.print("{d}.{d}.{d}.{d}:{d}", .{ parts[0], parts[1], parts[2], parts[3], port });
......@@ -157,11 +155,10 @@ pub const Ip6Address = extern struct {
157155 };
158156 }
159157
160 pub fn format(adr: Ip6Address, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
161 _ = adr;
162 _ = fmt;
163 _ = options;
164 try writer.writeAll("{Ip6Address}");
158 pub fn nprint(adr: Ip6Address, writer: anytype) !void {
159 const parts: [8]u16 = @bitCast(adr.sa.addr.addr);
160 const port = @byteSwap(adr.sa.port);
161 try writer.print("{x}.{x}.{x}.{x}.{x}.{x}.{x}.{x}:{d}", .{ parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6], parts[7], port });
165162 }
166163};
167164