开起来tfto
This commit is contained in:
parent
66a08a9c05
commit
bec0d21d20
@ -4,7 +4,7 @@ version = "1.0.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
smol = "1" # or any other runtime/executor
|
||||
tokio = "1.47.1"
|
||||
async-tftp = "0.3.6"
|
||||
slint = "1.12.1"
|
||||
rfd = "0.15.4"
|
||||
|
35
src/main.rs
35
src/main.rs
@ -1,15 +1,18 @@
|
||||
// use async_tftp::server::TftpServerBuilder;
|
||||
// use async_tftp::Result;
|
||||
use async_tftp::server::TftpServerBuilder;
|
||||
use async_tftp::Result;
|
||||
use rfd::FileDialog;
|
||||
use slint::SharedString;
|
||||
use std::error::Error;
|
||||
// ?use smol::{prelude::*};
|
||||
|
||||
slint::include_modules!();
|
||||
// fn main() -> Result<()> {
|
||||
// smol::block_on(async {
|
||||
// let tftpd = TftpServerBuilder::with_dir_ro("C:/Users/anonymous/Desktop/Rust/VoiletTftp/target/debug")?.build().await?;
|
||||
// tftpd.serve().await?;
|
||||
// Ok(())
|
||||
// })
|
||||
// }
|
||||
|
||||
async fn StartTftpServer(Dir: &str) -> Result<()> {
|
||||
println!("Start Tftp Server Dir With:{Dir}");
|
||||
let tftpd = TftpServerBuilder::with_dir_ro(Dir)?.build().await?;
|
||||
tftpd.serve().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let ui = MainWindow::new().unwrap();
|
||||
@ -26,19 +29,11 @@ fn main() {
|
||||
});
|
||||
//启动按钮的回调函数
|
||||
ui.on_StartTftp(move || {
|
||||
println!("Start Tftp Dir:");
|
||||
// smol::spawn(StartTftpServer("C:/Users/anonymous/Desktop/Rust/VoiletTftp/target/release/")).detach();
|
||||
});
|
||||
//停止按钮的回调函数
|
||||
ui.on_StopTftp(move || {
|
||||
println!("Stop Tftp Dir:");
|
||||
});
|
||||
ui.run().unwrap();
|
||||
// // 实现 Slint 中定义的 select_path 函数
|
||||
// ui.global::<MainWindow>().invoke_select_path(move || {
|
||||
// // 使用 rfd 库打开文件选择对话框
|
||||
// if let Some(path) = FileDialog::new().pick_folder() {
|
||||
// // 将选择的路径设置到 Slint 的 selected_path 属性中
|
||||
// ui.global::<MainWindow>().set_selected_path(path.to_str().unwrap_or(""));
|
||||
// }
|
||||
// });
|
||||
}
|
||||
}
|
||||
//启动一个TFTP服务器帮我改写
|
Loading…
x
Reference in New Issue
Block a user