blob: 96bcd168f388c3f265fba89235ea6caa03f32460 [file] [log] [blame]
// 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 fidl_test_ping::{PingRequest, PingRequestStream};
use fuchsia_async as fasync;
use fuchsia_component::server::ServiceFs;
use futures::prelude::*;
enum IncomingRequest {
Ping(PingRequestStream),
}
#[fasync::run_singlethreaded]
async fn main() {
let mut fs = ServiceFs::new_local();
fs.dir("svc").add_fidl_service(IncomingRequest::Ping);
fs.take_and_serve_directory_handle().expect("failed to take startup handle");
fs.for_each_concurrent(0, |IncomingRequest::Ping(mut stream)| async move {
while let Some(PingRequest::Ping { ping, responder }) =
stream.try_next().await.expect("failed to read request")
{
responder.send(&format!("{} pong", ping)).expect("failed to send pong");
}
})
.await;
}