1
0

Use common rust formatting

This commit is contained in:
clerie 2023-01-03 22:13:01 +01:00
parent 698f36518d
commit aebcde3808

View File

@ -1,11 +1,8 @@
use axum::{ use axum::{
http::StatusCode,
response::{IntoResponse, Response},
routing::get, routing::get,
Router, Router,
response::{
IntoResponse,
Response,
},
http::StatusCode,
}; };
use std::net::SocketAddr; use std::net::SocketAddr;
@ -20,7 +17,7 @@ async fn main() {
let arg = if let Some(arg) = args.next() { let arg = if let Some(arg) = args.next() {
arg arg
} else { } else {
break break;
}; };
match arg.as_str() { match arg.as_str() {
@ -29,10 +26,10 @@ async fn main() {
println!("Use --listen <addr:port> bind the web service."); println!("Use --listen <addr:port> bind the web service.");
println!("Output will be on /metrics endpoint. HTTP 500 if something broke while scraping."); println!("Output will be on /metrics endpoint. HTTP 500 if something broke while scraping.");
std::process::exit(0); std::process::exit(0);
}, }
"--listen" => { "--listen" => {
listen = args.next().unwrap(); listen = args.next().unwrap();
}, }
unknown => { unknown => {
println!("unknown option: {}", unknown); println!("unknown option: {}", unknown);
std::process::exit(1) std::process::exit(1)
@ -53,10 +50,11 @@ async fn main() {
fn get_current_system() -> Result<(String, String), String> { fn get_current_system() -> Result<(String, String), String> {
let symlink = match std::fs::read_link("/run/current-system") { let symlink = match std::fs::read_link("/run/current-system") {
Ok(symlink) => symlink, Ok(symlink) => symlink,
Err(err) => return Err(err.to_string()) Err(err) => return Err(err.to_string()),
}; };
let (hash, name) = symlink.file_name() let (hash, name) = symlink
.file_name()
.ok_or_else(String::default)? .ok_or_else(String::default)?
.to_str() .to_str()
.ok_or_else(String::default)? .ok_or_else(String::default)?
@ -72,7 +70,7 @@ async fn metrics() -> Response {
Ok((hash, name)) => (hash, name), Ok((hash, name)) => (hash, name),
Err(err) => { Err(err) => {
println!("failed: {}", err); println!("failed: {}", err);
return (StatusCode::INTERNAL_SERVER_ERROR, "").into_response() return (StatusCode::INTERNAL_SERVER_ERROR, "").into_response();
} }
}; };