feat(linux): add toStr method to each struct

This commit is contained in:
utox39
2025-05-01 19:07:09 +02:00
parent 6fdde01ac9
commit 4252a9f10a
3 changed files with 28 additions and 0 deletions

View File

@@ -8,6 +8,10 @@ const c_socket = @cImport(@cInclude("sys/socket.h"));
pub const NetInfo = struct {
interface_name: []u8,
ipv4_addr: []u8,
pub fn toStr(self: NetInfo, buf: []u8) ![]u8 {
return std.fmt.bufPrint(buf, "Local IP ({s}): {s}", .{ self.interface_name, self.ipv4_addr });
}
};
pub fn getNetInfo(allocator: std.mem.Allocator) !std.ArrayList(NetInfo) {