lws_client/src/client.rs

42 lines
1.1 KiB
Rust
Raw Normal View History

use lws_client::LwsVfsIns;
use std::thread;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let lws_ins = match LwsVfsIns::new("config.json").await {
Ok(ins) => ins,
Err(e) => {
println!("Error creating lws server instance: {:?}", e);
return Err(e);
}
};
println!("start hello process");
match lws_ins.hello().await {
Err(e) => {
println!("lws client instance hello err {:?}", e);
return Err(e);
}
_ => {}
}
println!("start mount process");
let handle = thread::spawn(move ||{
match LwsVfsIns::mount(lws_ins) {
Ok(_) => {
Ok::<i32, String>(0)
},
Err(e) => {
println!("mount err {:?}", e);
Ok::<i32, String>(-1)
}
}
});
match handle.join() {
Ok(_) => {
Ok(())
},
Err(e) => {
eprintln!("mount thread start err {:?}", e);
Err(Box::new(std::io::Error::new(std::io::ErrorKind::Other, "mount fail")))
}
}
}