1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use {
anyhow::{Context as _, Error},
config::Config,
fidl_test_exampletester::{SimpleMarker, SimpleSynchronousProxy},
fuchsia_component::client::connect_channel_to_protocol,
fuchsia_zircon as zx,
std::{thread, time},
};
fn main() -> Result<(), Error> {
println!("Started");
println!("trim me (Rust)");
let config = Config::take_from_startup_handle();
if config.do_in_process {
println!("Response: {:?}", config.augend + config.addend);
} else {
let (client_end, server_end) = zx::Channel::create();
connect_channel_to_protocol::<SimpleMarker>(server_end)
.context("Failed to connect to simple service")?;
println!("Outgoing connection enabled");
let simple = SimpleSynchronousProxy::new(client_end);
let res = simple.add(config.augend, config.addend, zx::Time::INFINITE)?;
println!("Response: {:?}", res);
}
thread::sleep(time::Duration::from_secs(2));
Ok(())
}