| ... | ... | @@ -49,10 +49,10 @@ pub const Address = extern union { |
| 49 | 49 | }; |
| 50 | 50 | } |
| 51 | 51 | |
| 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 | 53 | 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), |
| 56 | 56 | else => |a| try writer.print("{{any:{s}}}", .{@tagName(a)}), |
| 57 | 57 | } |
| 58 | 58 | } |
| ... | ... | @@ -132,9 +132,7 @@ pub const Ip4Address = extern struct { |
| 132 | 132 | }; |
| 133 | 133 | } |
| 134 | 134 | |
| 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 { |
| 138 | 136 | const parts: [4]u8 = @bitCast(adr.sa.addr.addr); |
| 139 | 137 | const port = @byteSwap(adr.sa.port); |
| 140 | 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 | 155 | }; |
| 158 | 156 | } |
| 159 | 157 | |
| 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 }); |
| 165 | 162 | } |
| 166 | 163 | }; |
| 167 | 164 | |