/// Create a `DirectoryEntry` and `Channel` pair. The created `DirectoryEntry`
/// provides the service `S`, sending all requests to the returned channel.
Create a `DirectoryEntry` and `Channel` pair. The created `DirectoryEntry`
provides the service `S`, sending all requests to the returned channel.
Create a ` DirectoryEntry ` and ` Channel ` pair . The created ` DirectoryEntry ` provides the service ` S ` sending all requests to the returned channel .
pub fn create_service_directory_entry<S>(
) -> (Arc<dyn DirectoryEntry>, futures::channel::mpsc::Receiver<fidl::endpoints::Request<S>>)
where
    S: fidl::endpoints::ServiceMarker,
    fidl::endpoints::Request<S>: Send,
{
    use futures::sink::SinkExt;
    let (sender, receiver) = futures::channel::mpsc::channel(0);
    let entry = directory_broker::DirectoryBroker::new(Box::new(
        move |_flags: u32,
              _mode: u32,
              _relative_path: String,
              server_end: ServerEnd<fidl_fuchsia_io::NodeMarker>| {
            let mut sender = sender.clone();
            fasync::Task::spawn(async move {
                // Convert the stream into a channel of the correct service.
                let server_end: ServerEnd<S> = ServerEnd::new(server_end.into_channel());
                let mut stream: S::RequestStream = server_end.into_stream().unwrap();
                // Keep handling requests until the stream closes or the handler returns an error.
                while let Ok(Some(request)) = stream.try_next().await {
                    sender.send(request).await.unwrap();
                }
            })
            .detach();
        },
    ));
    (entry, receiver)
}
pub fn create_service_directory_entry < S > ( ) -> ( Arc < dyn DirectoryEntry > , futures :: channel :: mpsc :: Receiver < fidl :: endpoints :: Request < S > > ) where S : fidl :: endpoints :: ServiceMarker , fidl :: endpoints :: Request < S > : Send , { use futures :: sink :: SinkExt ; let ( sender , receiver ) = futures :: channel :: mpsc :: channel ( 0 ) ; let entry = directory_broker :: DirectoryBroker :: new ( Box :: new ( move | _flags : u32 , _mode : u32 , _relative_path : String , server_end : ServerEnd < fidl_fuchsia_io :: NodeMarker > | { let mut sender = sender . clone ( ) ; fasync :: Task :: spawn ( async move { // Convert the stream into a channel of the correct service. let server_end : ServerEnd < S > = ServerEnd :: new ( server_end . into_channel ( ) ) ; let mut stream : S :: RequestStream = server_end . into_stream ( ) . unwrap ( ) ; // Keep handling requests until the stream closes or the handler returns an error. while let Ok ( Some ( request ) ) = stream . try_next ( ) . await { sender . send ( request ) . await . unwrap ( ) ; } } ) . detach ( ) ; } , ) ) ; ( entry , receiver ) }
Create a `DirectoryEntry` and `Channel` pair.
Create a ` DirectoryEntry ` and ` Channel ` pair .