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 {...@@ -49,10 +49,10 @@ pub const Address = extern union {
49 };49 };
50 }50 }
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 {
53 switch (adr.any.family) {53 switch (adr.any.family) {
54 .INET => try adr.in.format(fmt, options, writer),54 .INET => try adr.in.nprint(writer),
55 .INET6 => try adr.in6.format(fmt, options, writer),55 .INET6 => try adr.in6.nprint(writer),
56 else => |a| try writer.print("{{any:{s}}}", .{@tagName(a)}),56 else => |a| try writer.print("{{any:{s}}}", .{@tagName(a)}),
57 }57 }
58 }58 }
...@@ -132,9 +132,7 @@ pub const Ip4Address = extern struct {...@@ -132,9 +132,7 @@ pub const Ip4Address = extern struct {
132 };132 };
133 }133 }
134134
135 pub fn format(adr: Ip4Address, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {135 pub fn nprint(adr: Ip4Address, writer: anytype) !void {
136 _ = fmt;
137 _ = options;
138 const parts: [4]u8 = @bitCast(adr.sa.addr.addr);136 const parts: [4]u8 = @bitCast(adr.sa.addr.addr);
139 const port = @byteSwap(adr.sa.port);137 const port = @byteSwap(adr.sa.port);
140 try writer.print("{d}.{d}.{d}.{d}:{d}", .{ parts[0], parts[1], parts[2], parts[3], port });138 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 {...@@ -157,11 +155,10 @@ pub const Ip6Address = extern struct {
157 };155 };
158 }156 }
159157
160 pub fn format(adr: Ip6Address, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {158 pub fn nprint(adr: Ip6Address, writer: anytype) !void {
161 _ = adr;159 const parts: [8]u16 = @bitCast(adr.sa.addr.addr);
162 _ = fmt;160 const port = @byteSwap(adr.sa.port);
163 _ = options;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 });
164 try writer.writeAll("{Ip6Address}");
165 }162 }
166};163};
167164