pub fn start(ns_map: HashMap<PathBuf, DirectoryProxy>, chan: zx::Channel) {
    fasync::spawn(
        async move {
            // Wait for requests
            let mut stream =
                LoaderRequestStream::from_channel(fasync::Channel::from_channel(chan)?);
            while let Some(req) = await!(stream.try_next())? {
                match req {
                    LoaderRequest::Done { control_handle } => {
                        control_handle.shutdown();
                    }
                    LoaderRequest::LoadObject { object_name, responder } => {
                        // TODO(ZX-3392): The name provided by the client here has a null byte at
                        // the end, which doesn't work from here on out (io.fidl doesn't like it).
                        let object_name = object_name.trim_matches(char::from(0));
                        let object_path = PKG_PATH.join("lib").join(object_name);
                        match await!(load_object(&ns_map, PathBuf::from(object_path))) {
                            Ok(b) => responder.send(zx::sys::ZX_OK, Some(b))?,
                            Err(e) => {
                                warn!("failed to load object: {}", e);
                                responder.send(zx::sys::ZX_ERR_NOT_FOUND, None)?;
                            }
                        };
                    }
                    LoaderRequest::LoadScriptInterpreter { interpreter_name: _, responder } => {
                        // Unimplemented
                        responder.control_handle().shutdown();
                    }
                    LoaderRequest::Config { config: _, responder } => {
                        // Unimplemented
                        responder.control_handle().shutdown();
                    }
                    LoaderRequest::Clone { loader, responder } => {
                        let new_ns_map = ns_util::clone_component_namespace_map(&ns_map)?;
                        start(new_ns_map, loader.into_channel());
                        responder.send(zx::sys::ZX_OK)?;
                    }
                    LoaderRequest::DebugPublishDataSink { data_sink: _, data: _, responder } => {
                        // Unimplemented
                        responder.control_handle().shutdown();
                    }
                    LoaderRequest::DebugLoadConfig { config_name: _, responder } => {
                        // Unimplemented
                        responder.control_handle().shutdown();
                    }
                }
            }
            Ok(())
        }
            .unwrap_or_else(|e: Error| warn!("couldn't run library loader service: {}", e)),
    ); // TODO
}
/// start will expose the ldsvc.fidl service over the given channel, providing VMO buffers of
/// requested library object names from the given namespace.
start will expose the ldsvc.fidl service over the given channel, providing VMO buffers of
requested library object names from the given namespace.
start will expose the ldsvc . fidl service over the given channel providing VMO buffers of requested library object names from the given namespace .
pub fn start(ns_map: HashMap<PathBuf, DirectoryProxy>, chan: zx::Channel) {
    fasync::spawn(
        async move {
            // Wait for requests
            let mut stream =
                LoaderRequestStream::from_channel(fasync::Channel::from_channel(chan)?);
            while let Some(req) = await!(stream.try_next())? {
                match req {
                    LoaderRequest::Done { control_handle } => {
                        control_handle.shutdown();
                    }
                    LoaderRequest::LoadObject { object_name, responder } => {
                        // TODO(ZX-3392): The name provided by the client here has a null byte at
                        // the end, which doesn't work from here on out (io.fidl doesn't like it).
                        let object_name = object_name.trim_matches(char::from(0));
                        let object_path = PKG_PATH.join("lib").join(object_name);
                        match await!(load_object(&ns_map, PathBuf::from(object_path))) {
                            Ok(b) => responder.send(zx::sys::ZX_OK, Some(b))?,
                            Err(e) => {
                                warn!("failed to load object: {}", e);
                                responder.send(zx::sys::ZX_ERR_NOT_FOUND, None)?;
                            }
                        };
                    }
                    LoaderRequest::LoadScriptInterpreter { interpreter_name: _, responder } => {
                        // Unimplemented
                        responder.control_handle().shutdown();
                    }
                    LoaderRequest::Config { config: _, responder } => {
                        // Unimplemented
                        responder.control_handle().shutdown();
                    }
                    LoaderRequest::Clone { loader, responder } => {
                        let new_ns_map = ns_util::clone_component_namespace_map(&ns_map)?;
                        start(new_ns_map, loader.into_channel());
                        responder.send(zx::sys::ZX_OK)?;
                    }
                    LoaderRequest::DebugPublishDataSink { data_sink: _, data: _, responder } => {
                        // Unimplemented
                        responder.control_handle().shutdown();
                    }
                    LoaderRequest::DebugLoadConfig { config_name: _, responder } => {
                        // Unimplemented
                        responder.control_handle().shutdown();
                    }
                }
            }
            Ok(())
        }
            .unwrap_or_else(|e: Error| warn!("couldn't run library loader service: {}", e)),
    ); // TODO
}
pub fn start ( ns_map : HashMap < PathBuf , DirectoryProxy > , chan : zx :: Channel ) { fasync :: spawn ( async move { // Wait for requests let mut stream = LoaderRequestStream :: from_channel ( fasync :: Channel :: from_channel ( chan ) ? ) ; while let Some ( req ) = await ! ( stream try_next ( ) ) ? { match req { LoaderRequest :: Done { control_handle } => { control_handle . shutdown ( ) ; } LoaderRequest :: LoadObject { object_name , responder } => { // TODO(ZX-3392): The name provided by the client here has a null byte at // the end, which doesn't work from here on out (io.fidl doesn't like it). let object_name = object_name . trim_matches ( char :: from ( 0 ) ) ; let object_path = PKG_PATH . join ( " " ) . join ( object_name ) ; match await ! ( load_object ( ns_map PathBuf from ( object_path ) ) ) { Ok ( b ) => responder . send ( zx :: sys :: ZX_OK , Some ( b ) ) ? , Err ( e ) => { warn ! ( " " e ) ; responder . send ( zx :: sys :: ZX_ERR_NOT_FOUND , None ) ? ; } } ; } LoaderRequest :: LoadScriptInterpreter { interpreter_name : _ , responder } => { // Unimplemented responder . control_handle ( ) . shutdown ( ) ; } LoaderRequest :: Config { config : _ , responder } => { // Unimplemented responder . control_handle ( ) . shutdown ( ) ; } LoaderRequest :: Clone { loader , responder } => { let new_ns_map = ns_util :: clone_component_namespace_map ( & ns_map ) ? ; start ( new_ns_map , loader . into_channel ( ) ) ; responder . send ( zx :: sys :: ZX_OK ) ? ; } LoaderRequest :: DebugPublishDataSink { data_sink : _ , data : _ , responder } => { // Unimplemented responder . control_handle ( ) . shutdown ( ) ; } LoaderRequest :: DebugLoadConfig { config_name : _ , responder } => { // Unimplemented responder . control_handle ( ) . shutdown ( ) ; } } } Ok ( ( ) ) } . unwrap_or_else ( | e : Error | warn ! ( " " e ) ) , ) ; // TODO }
start will expose the ldsvc.fidl service over the given channel, providing VMO buffers of
requested library object names from the given namespace.
start will expose the ldsvc . fidl service over the given channel providing VMO buffers of requested library object names from the given namespace .
ns_map
HashMap<PathBuf, DirectoryProxy>
chan
zx::Channel
ns_map
HashMap<PathBuf, DirectoryProxy>
chan
zx::Channel