fuchsia_component_client/
fidl_next.rs1use fidl_next::{ClientEnd, Discoverable, ServerEnd};
8
9use super::{Error, SVC_DIR, connect_channel_to_protocol_at_path};
10
11pub fn connect_server_end_to_protocol_at<P: Discoverable>(
14 server_end: ServerEnd<P>,
15 service_directory_path: &str,
16) -> Result<(), Error> {
17 let protocol_path = format!("{}/{}", service_directory_path, P::PROTOCOL_NAME);
18 connect_channel_to_protocol_at_path(server_end.into_untyped(), &protocol_path)
19}
20
21pub fn connect_to_protocol_at<P: Discoverable>(
23 service_prefix: &str,
24) -> Result<ClientEnd<P>, Error> {
25 let (client_end, server_end) = fidl_next::fuchsia::create_channel();
26 let () = connect_server_end_to_protocol_at(server_end, service_prefix)?;
27 Ok(client_end)
28}
29
30pub fn connect_to_protocol<P: Discoverable>() -> Result<ClientEnd<P>, Error> {
33 connect_to_protocol_at(SVC_DIR)
34}