refactor: add comments
This commit is contained in:
@@ -6,6 +6,7 @@ const c_cf = @cImport(@cInclude("CoreFoundation/CoreFoundation.h"));
|
|||||||
const c_mach = @cImport(@cInclude("mach/mach.h"));
|
const c_mach = @cImport(@cInclude("mach/mach.h"));
|
||||||
const c_statvfs = @cImport(@cInclude("sys/statvfs.h"));
|
const c_statvfs = @cImport(@cInclude("sys/statvfs.h"));
|
||||||
|
|
||||||
|
/// Struct representing CPU informations
|
||||||
pub const CpuInfo = struct {
|
pub const CpuInfo = struct {
|
||||||
cpu_name: []u8,
|
cpu_name: []u8,
|
||||||
cpu_cores: i32,
|
cpu_cores: i32,
|
||||||
@@ -16,6 +17,7 @@ pub const CpuInfo = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Struct representing GPU informations
|
||||||
pub const GpuInfo = struct {
|
pub const GpuInfo = struct {
|
||||||
gpu_name: []u8,
|
gpu_name: []u8,
|
||||||
gpu_cores: i32,
|
gpu_cores: i32,
|
||||||
@@ -26,6 +28,7 @@ pub const GpuInfo = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Struct representing RAM usage informations
|
||||||
pub const RamInfo = struct {
|
pub const RamInfo = struct {
|
||||||
ram_size: f64,
|
ram_size: f64,
|
||||||
ram_usage: f64,
|
ram_usage: f64,
|
||||||
@@ -36,6 +39,7 @@ pub const RamInfo = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Struct representing Swap usage informations
|
||||||
pub const SwapInfo = struct {
|
pub const SwapInfo = struct {
|
||||||
swap_size: f64,
|
swap_size: f64,
|
||||||
swap_usage: f64,
|
swap_usage: f64,
|
||||||
@@ -46,6 +50,7 @@ pub const SwapInfo = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Struct representing Disk usage informations
|
||||||
pub const DiskInfo = struct {
|
pub const DiskInfo = struct {
|
||||||
disk_path: []const u8,
|
disk_path: []const u8,
|
||||||
disk_size: f64,
|
disk_size: f64,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const c_net_if = @cImport(@cInclude("net/if.h"));
|
|||||||
const c_netinet_in = @cImport(@cInclude("netinet/in.h"));
|
const c_netinet_in = @cImport(@cInclude("netinet/in.h"));
|
||||||
const c_socket = @cImport(@cInclude("sys/socket.h"));
|
const c_socket = @cImport(@cInclude("sys/socket.h"));
|
||||||
|
|
||||||
|
/// Struct representing Network informations (interface name - ipv4 address)
|
||||||
pub const NetInfo = struct {
|
pub const NetInfo = struct {
|
||||||
interface_name: []u8,
|
interface_name: []u8,
|
||||||
ipv4_addr: []u8,
|
ipv4_addr: []u8,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const std = @import("std");
|
|||||||
const c_sysctl = @cImport(@cInclude("sys/sysctl.h"));
|
const c_sysctl = @cImport(@cInclude("sys/sysctl.h"));
|
||||||
const c_libproc = @cImport(@cInclude("libproc.h"));
|
const c_libproc = @cImport(@cInclude("libproc.h"));
|
||||||
|
|
||||||
/// Structure representing system uptime in days, hours, and minutes.
|
/// Struct representing system uptime in days, hours, and minutes.
|
||||||
pub const SystemUptime = struct {
|
pub const SystemUptime = struct {
|
||||||
days: i8,
|
days: i8,
|
||||||
hours: i8,
|
hours: i8,
|
||||||
@@ -13,6 +13,7 @@ pub const SystemUptime = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Struct representing Kernel informations
|
||||||
pub const KernelInfo = struct {
|
pub const KernelInfo = struct {
|
||||||
kernel_name: []u8,
|
kernel_name: []u8,
|
||||||
kernel_release: []u8,
|
kernel_release: []u8,
|
||||||
@@ -22,7 +23,7 @@ pub const KernelInfo = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns the hostname.
|
/// Returns the hostname.
|
||||||
pub fn getHostname(allocator: std.mem.Allocator) ![]u8 {
|
pub fn getHostname(allocator: std.mem.Allocator) ![]u8 {
|
||||||
var buf: [std.posix.HOST_NAME_MAX]u8 = undefined;
|
var buf: [std.posix.HOST_NAME_MAX]u8 = undefined;
|
||||||
const hostnameEnv = try std.posix.gethostname(&buf);
|
const hostnameEnv = try std.posix.gethostname(&buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user