mirror of
https://github.com/OMGeeky/gdriver2.git
synced 2026-02-15 07:34:51 +01:00
29 lines
861 B
Rust
29 lines
861 B
Rust
use gdriver_common::config::CONFIGURATION;
|
|
|
|
use super::*;
|
|
pub async fn start() -> Result<()> {
|
|
println!("Hello, world!");
|
|
|
|
let name = "test1".to_string();
|
|
let config = &CONFIGURATION;
|
|
let client: WorldClient = create_client(&config.socket_path).await?;
|
|
|
|
let hello = client
|
|
.hello(tarpc::context::current(), name.to_string())
|
|
.await;
|
|
|
|
match hello {
|
|
Ok(hello) => println!("{hello:?}"),
|
|
Err(e) => println!("{:?}", (e)),
|
|
}
|
|
Ok(())
|
|
}
|
|
pub async fn create_client(socket_path: impl AsRef<Path>) -> Result<WorldClient> {
|
|
let transport = tarpc::serde_transport::unix::connect(socket_path, Json::default)
|
|
.await
|
|
.inspect_err(|_| println!("Could not connect"))?;
|
|
let var_name = WorldClient::new(client::Config::default(), transport);
|
|
let client = var_name.spawn();
|
|
Ok(client)
|
|
}
|