2024-07-24 13:19:40 +08:00
|
|
|
use lws_client::LwsVfsIns;
|
|
|
|
use std::thread;
|
2024-08-04 17:57:26 +08:00
|
|
|
extern crate log;
|
|
|
|
|
2024-07-24 13:19:40 +08:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
2024-08-04 17:57:26 +08:00
|
|
|
env_logger::init();
|
2024-07-24 13:19:40 +08:00
|
|
|
let lws_ins = match LwsVfsIns::new("config.json").await {
|
|
|
|
Ok(ins) => ins,
|
|
|
|
Err(e) => {
|
2024-08-04 17:57:26 +08:00
|
|
|
log::error!("Error creating lws server instance: {:?}", e);
|
2024-07-24 13:19:40 +08:00
|
|
|
return Err(e);
|
|
|
|
}
|
|
|
|
};
|
2024-08-04 17:57:26 +08:00
|
|
|
log::info!("lws client instance created");
|
2024-07-24 13:19:40 +08:00
|
|
|
match lws_ins.hello().await {
|
|
|
|
Err(e) => {
|
2024-08-04 17:57:26 +08:00
|
|
|
log::error!("lws client instance hello err {:?}", e);
|
2024-07-24 13:19:40 +08:00
|
|
|
return Err(e);
|
|
|
|
}
|
|
|
|
_ => {}
|
|
|
|
}
|
2024-08-04 17:57:26 +08:00
|
|
|
log::info!("start mount process");
|
2024-07-24 13:19:40 +08:00
|
|
|
let handle = thread::spawn(move ||{
|
|
|
|
match LwsVfsIns::mount(lws_ins) {
|
|
|
|
Ok(_) => {
|
|
|
|
Ok::<i32, String>(0)
|
|
|
|
},
|
|
|
|
Err(e) => {
|
2024-08-04 17:57:26 +08:00
|
|
|
log::error!("mount err {:?}", e);
|
2024-07-24 13:19:40 +08:00
|
|
|
Ok::<i32, String>(-1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
match handle.join() {
|
|
|
|
Ok(_) => {
|
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
Err(e) => {
|
2024-08-04 17:57:26 +08:00
|
|
|
log::error!("mount thread start err {:?}", e);
|
2024-07-24 13:19:40 +08:00
|
|
|
Err(Box::new(std::io::Error::new(std::io::ErrorKind::Other, "mount fail")))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|