diff options
| author | Fuwn <[email protected]> | 2024-06-03 15:23:14 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-03 15:23:14 +0000 |
| commit | 303ed249037821be0e947b790ecb6090c89cc832 (patch) | |
| tree | 07d1449bb77f12eae0bd90344eee37440291167b /crates/whirl_api/src | |
| parent | chore(rustfmt): add new rules (diff) | |
| download | whirl-303ed249037821be0e947b790ecb6090c89cc832.tar.xz whirl-303ed249037821be0e947b790ecb6090c89cc832.zip | |
format: rustfmt with new rules
Diffstat (limited to 'crates/whirl_api/src')
| -rw-r--r-- | crates/whirl_api/src/lib.rs | 6 | ||||
| -rw-r--r-- | crates/whirl_api/src/routes/stats/mod.rs | 24 | ||||
| -rw-r--r-- | crates/whirl_api/src/routes/worlds/info/mod.rs | 4 | ||||
| -rw-r--r-- | crates/whirl_api/src/routes/worlds/vip/mod.rs | 16 |
4 files changed, 27 insertions, 23 deletions
diff --git a/crates/whirl_api/src/lib.rs b/crates/whirl_api/src/lib.rs index 9051f4c..589fda0 100644 --- a/crates/whirl_api/src/lib.rs +++ b/crates/whirl_api/src/lib.rs @@ -19,10 +19,8 @@ html_favicon_url = "https://raw.githubusercontent.com/Whirlsplash/assets/master/Whirl.png" )] -#[macro_use] -extern crate log; -#[macro_use] -extern crate serde_derive; +#[macro_use] extern crate log; +#[macro_use] extern crate serde_derive; use axum::routing::get; diff --git a/crates/whirl_api/src/routes/stats/mod.rs b/crates/whirl_api/src/routes/stats/mod.rs index 05b9bc7..0898902 100644 --- a/crates/whirl_api/src/routes/stats/mod.rs +++ b/crates/whirl_api/src/routes/stats/mod.rs @@ -3,12 +3,14 @@ pub mod structures; -use std::convert::TryFrom; - -use axum::response; -use sysinfo::{get_current_pid, ProcessExt, System, SystemExt}; - -use crate::routes::stats::structures::{Statistics, StatisticsProcess, StatisticsSystem}; +use { + crate::routes::stats::structures::{ + Statistics, StatisticsProcess, StatisticsSystem, + }, + axum::response, + std::convert::TryFrom, + sysinfo::{get_current_pid, ProcessExt, System, SystemExt}, +}; // This is mostly for developmental testing, it consumes more CPU than it's // worth. @@ -25,13 +27,17 @@ pub async fn statistics() -> impl response::IntoResponse { system: StatisticsSystem { os_type: sys.name().unwrap(), release: sys.kernel_version().unwrap(), - uptime: whirl_common::system::unixts_to_hrtime(usize::try_from(sys.uptime()).unwrap()), + uptime: whirl_common::system::unixts_to_hrtime( + usize::try_from(sys.uptime()).unwrap(), + ), }, process: StatisticsProcess { // (process.cpu_usage() * 100.0).round() / 100.0 memory_usage: (process.memory() / 1000).to_string(), - cpu_usage: (process.cpu_usage() / sys.processors().len() as f32).to_string(), - // uptime: seconds_to_hrtime((sys.get_uptime() - process.start_time()) as usize), + cpu_usage: (process.cpu_usage() / sys.processors().len() as f32) + .to_string(), + // uptime: seconds_to_hrtime((sys.get_uptime() - process.start_time()) + // as usize), }, }), ) diff --git a/crates/whirl_api/src/routes/worlds/info/mod.rs b/crates/whirl_api/src/routes/worlds/info/mod.rs index ea04112..382c07f 100644 --- a/crates/whirl_api/src/routes/worlds/info/mod.rs +++ b/crates/whirl_api/src/routes/worlds/info/mod.rs @@ -7,7 +7,9 @@ pub struct Parameters { } #[allow(clippy::needless_pass_by_value, clippy::unused_async)] -pub async fn info(axum::extract::Query(req): axum::extract::Query<Parameters>) -> &'static str { +pub async fn info( + axum::extract::Query(req): axum::extract::Query<Parameters>, +) -> &'static str { let mut easy = curl::easy::Easy::new(); easy diff --git a/crates/whirl_api/src/routes/worlds/vip/mod.rs b/crates/whirl_api/src/routes/worlds/vip/mod.rs index 7b7aee0..f53be55 100644 --- a/crates/whirl_api/src/routes/worlds/vip/mod.rs +++ b/crates/whirl_api/src/routes/worlds/vip/mod.rs @@ -3,11 +3,10 @@ mod structures; -use std::str::from_utf8; - -use axum::response; - -use crate::routes::worlds::vip::structures::Vip; +use { + crate::routes::worlds::vip::structures::Vip, axum::response, + std::str::from_utf8, +}; #[derive(Serialize, Deserialize)] pub struct Parameters { @@ -23,11 +22,10 @@ pub async fn vip( let username = req.username; if username.is_none() - || username - .as_ref() - .map_or(false, std::string::String::is_empty) + || username.as_ref().map_or(false, std::string::String::is_empty) { - error = "no username query parameter provided, defaulting to 'null'".to_string(); + error = + "no username query parameter provided, defaulting to 'null'".to_string(); } easy |