The memory information is returned in bytes and not kb.

Fix the documentation of the Information struct, and the example
system_information that uses it.

Co-authored-by: =?UTF-8?q?Ahmet=20Kaan=20G=C3=9CM=C3=9C=C5=9E?= <96421894+Tahinli@users.noreply.github.com>
This commit is contained in:
brianch 2024-01-31 15:00:13 -03:00 committed by Héctor Ramón Jiménez
parent aea172543c
commit 701bf22af6
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 6 additions and 6 deletions

View file

@ -102,19 +102,19 @@ impl Application for Example {
));
let memory_readable =
ByteSize::kb(information.memory_total).to_string();
ByteSize::b(information.memory_total).to_string();
let memory_total = text(format!(
"Memory (total): {} kb ({memory_readable})",
"Memory (total): {} bytes ({memory_readable})",
information.memory_total,
));
let memory_text = if let Some(memory_used) =
information.memory_used
{
let memory_readable = ByteSize::kb(memory_used).to_string();
let memory_readable = ByteSize::b(memory_used).to_string();
format!("{memory_used} kb ({memory_readable})")
format!("{memory_used} bytes ({memory_readable})")
} else {
String::from("None")
};

View file

@ -18,9 +18,9 @@ pub struct Information {
pub cpu_brand: String,
/// The number of physical cores on the processor
pub cpu_cores: Option<usize>,
/// Total RAM size, KB
/// Total RAM size, in bytes
pub memory_total: u64,
/// Memory used by this process, KB
/// Memory used by this process, in bytes
pub memory_used: Option<u64>,
/// Underlying graphics backend for rendering
pub graphics_backend: String,