mirror of
https://github.com/NotAShelf/microfetch.git
synced 2026-04-12 12:57:41 +00:00
microfetch: consume library exports in binary crate
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Id6c10efbb185fc44fcf22e6ab5c94a266a6a6964
This commit is contained in:
parent
bf1b319971
commit
b4d3b9203a
1 changed files with 5 additions and 14 deletions
19
src/main.rs
19
src/main.rs
|
|
@ -1,18 +1,11 @@
|
||||||
mod colors;
|
|
||||||
mod desktop;
|
|
||||||
mod release;
|
|
||||||
mod syscall;
|
|
||||||
mod system;
|
|
||||||
mod uptime;
|
|
||||||
|
|
||||||
use std::io::{self, Cursor, Write};
|
use std::io::{self, Cursor, Write};
|
||||||
|
|
||||||
pub use microfetch_lib::UtsName;
|
use microfetch_lib::{
|
||||||
|
UtsName,
|
||||||
use crate::{
|
colors::{COLORS, print_dots},
|
||||||
colors::print_dots,
|
|
||||||
desktop::get_desktop_info,
|
desktop::get_desktop_info,
|
||||||
release::{get_os_pretty_name, get_system_info},
|
release::{get_os_pretty_name, get_system_info},
|
||||||
|
syscall::sys_write,
|
||||||
system::{
|
system::{
|
||||||
get_memory_usage,
|
get_memory_usage,
|
||||||
get_root_disk_usage,
|
get_root_disk_usage,
|
||||||
|
|
@ -64,8 +57,6 @@ struct Fields {
|
||||||
fn print_system_info(
|
fn print_system_info(
|
||||||
fields: &Fields,
|
fields: &Fields,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
use crate::colors::COLORS;
|
|
||||||
|
|
||||||
let Fields {
|
let Fields {
|
||||||
user_info,
|
user_info,
|
||||||
os_name,
|
os_name,
|
||||||
|
|
@ -102,7 +93,7 @@ fn print_system_info(
|
||||||
let len =
|
let len =
|
||||||
usize::try_from(cursor.position()).expect("cursor position fits usize");
|
usize::try_from(cursor.position()).expect("cursor position fits usize");
|
||||||
// Direct syscall to avoid stdout buffering allocation
|
// Direct syscall to avoid stdout buffering allocation
|
||||||
let written = unsafe { syscall::sys_write(1, buf.as_ptr(), len) };
|
let written = unsafe { sys_write(1, buf.as_ptr(), len) };
|
||||||
if written < 0 {
|
if written < 0 {
|
||||||
return Err(io::Error::last_os_error().into());
|
return Err(io::Error::last_os_error().into());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue