///|
/// A device's fake memory footprint: `used` and `total`, both in GiB.
/// Only these two numbers are picked by the model; the display text
/// (two-decimal GiB values and usage percentage) is derived from them.
pub struct Memory {
used : Float
total : Float
}
///|
/// Format as fastfetch does, e.g. `46.30 GiB / 128.00 GiB (36%)`.
pub fn Memory::render(self : Memory) -> String {
let percent = (self.used / self.total * 100.0).round().to_int()
"\{fixed_two(self.used)} GiB / \{fixed_two(self.total)} GiB (\{percent}%)"
}
///|
/// A display resolution: `width` and `height` in pixels.
pub struct Resolution {
width : Int
height : Int
}
///|
/// Format as fastfetch does, e.g. `3456x2234`.
pub fn Resolution::render(self : Resolution) -> String {
"\{self.width}x\{self.height}"
}
///|
/// System uptime in whole `hours` and `mins`.
pub struct Uptime {
hours : Int
mins : Int
}
///|
/// Format as fastfetch does, e.g. `3 hours, 12 mins`.
pub fn Uptime::render(self : Uptime) -> String {
"\{self.hours} hours, \{self.mins} mins"
}
///|
/// A CPU: vendor/model `name`, `cores`, and base `clock` in GHz.
pub struct Cpu {
name : String
cores : Int
clock : Float
}
///|
/// Format as fastfetch does, e.g. `Apple M3 Max (16) @ 4.05 GHz`.
pub fn Cpu::render(self : Cpu) -> String {
"\{self.name} (\{self.cores}) @ \{fixed_two(self.clock)} GHz"
}
///|
/// A GPU: vendor/model `name` and discrete VRAM in GB.
/// `vram` is 0 when the GPU has no discrete memory (integrated/Apple silicon).
pub struct Gpu {
name : String
vram : Int
}
///|
/// Format as fastfetch does, e.g. `NVIDIA GeForce RTX 4090 (24GB)`; a GPU
/// without discrete VRAM renders as its bare name.
pub fn Gpu::render(self : Gpu) -> String {
if self.vram > 0 {
"\{self.name} (\{self.vram}GB)"
} else {
self.name
}
}
///|
/// A coherent set of fake hardware/software values for one real device model.
/// Every field is a plausible, internally-consistent value for that product.
pub struct DeviceModel {
name : String
about : String
host : String
os : String
device : String
kernel : String
uptime : Uptime
shell : String
resolution : Resolution?
de : String
wm : String
wm_theme : String
terminal : String
term_font : String
cpu : Cpu
gpu : Gpu
memory : Memory
logo : String
}