migrate to rust version 2024

This commit is contained in:
April John 2025-02-28 18:15:54 +01:00
parent c099817e9a
commit 40af253450
4 changed files with 16 additions and 7 deletions

View file

@ -2,7 +2,7 @@
name = "hai" name = "hai"
version = "0.1.0" version = "0.1.0"
authors = ["April Faye John <april.john@denic.de>"] authors = ["April Faye John <april.john@denic.de>"]
edition = "2021" edition = "2024"
publish = false publish = false
license = "AGPL-3.0-or-later" license = "AGPL-3.0-or-later"

1
rustfmt.toml Normal file
View file

@ -0,0 +1 @@
style_edition = "2024"

View file

@ -6,7 +6,6 @@
use egui::{TextureOptions, Vec2}; use egui::{TextureOptions, Vec2};
pub fn gui_main() -> eframe::Result { pub fn gui_main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions { let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([600.0, 540.0]), viewport: egui::ViewportBuilder::default().with_inner_size([600.0, 540.0]),
..Default::default() ..Default::default()

View file

@ -10,10 +10,13 @@ mod gui;
mod pman; mod pman;
mod quic; mod quic;
use std::fs::File;
use std::net::SocketAddr;
use std::str::FromStr;
use bunt::println; use bunt::println;
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
use config::{Config, Source}; use config::{Config, FileFormat, Source};
use log::info; use log::{debug, info};
use pman::{init_process_manager, ProcessCommand, ProcessManager}; use pman::{init_process_manager, ProcessCommand, ProcessManager};
use shadow_rs::shadow; use shadow_rs::shadow;
use std::sync::{Arc, Mutex, OnceLock}; use std::sync::{Arc, Mutex, OnceLock};
@ -41,7 +44,7 @@ struct Args {
#[derive(Debug, Subcommand)] #[derive(Debug, Subcommand)]
enum Commands { enum Commands {
#[command(arg_required_else_help = true, about = "Start client without GUI")] #[command(about = "Start client without GUI")]
CliClient, CliClient,
#[command(about = "List compile time backed info to audit binary")] #[command(about = "List compile time backed info to audit binary")]
Shadow, Shadow,
@ -66,7 +69,10 @@ static CONFIG_FILE: OnceLock<Option<String>> = OnceLock::new();
fn get_config_file_source() -> impl Source { fn get_config_file_source() -> impl Source {
let file = CONFIG_FILE.get(); let file = CONFIG_FILE.get();
let default_dir = dirs::config_dir().unwrap(); let default_dir = dirs::config_dir().unwrap();
config::File::from_str(s, format) let file_buf = default_dir.join("hai").join("config.toml");
println!("{}", file_buf.to_string_lossy());
let file_content = std::fs::read_to_string(file_buf).unwrap();
config::File::from_str(&*file_content, FileFormat::Toml)
} }
#[tokio::main] #[tokio::main]
@ -81,7 +87,10 @@ async fn main() {
let _ = init_process_manager(); let _ = init_process_manager();
match args.command { match args.command {
Commands::CliClient => {} Commands::CliClient => {
let ip_addr_str = config().get_string("remote_endpoint").unwrap();
let ip_sock = SocketAddr::from_str(&ip_addr_str).unwrap();
}
Commands::Shadow => { Commands::Shadow => {
bininfo::print_info(); bininfo::print_info();