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
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

use anyhow::{Context as _, Error};
use fidl_fuchsia_examples::EchoServiceMarker;
use fuchsia_component::client::connect_to_service;

#[fuchsia::main]
async fn main() -> Result<(), Error> {
    let echo =
        connect_to_service::<EchoServiceMarker>().context("Failed to connect to echo service")?;

    let regular =
        echo.connect_to_regular_echo().context("failed to connect to regular_echo member")?;
    let regular_response = regular.echo_string("hello world!").await?;
    println!("regular response: {:?}", regular_response);

    let reversed =
        echo.connect_to_reversed_echo().context("failed to connect to reversed_echo member")?;
    let reversed_response = reversed.echo_string("hello world!").await?;
    println!("reversed response: {:?}", reversed_response);

    Ok(())
}