/// Add a service to the `ServicesServer` that will launch a component
/// upon request, proxying requests to the launched component.
Add a service to the `ServicesServer` that will launch a component
upon request, proxying requests to the launched component.
Add a service to the ` ServicesServer ` that will launch a component upon request proxying requests to the launched component .
pub fn add_component_proxy_service(
            self,
            service_name: &'static str,
            component_url: String,
            arguments: Option<Vec<String>>,
        ) -> Self {
            // Note: the launched app will live for the remaining lifetime of the
            // closure, which will be exactly as long as the lifetime of the resulting
            // `FdioServer`. When the `FdioServer` is dropped, the launched component
            // will be terminated.
            let mut launched_app = None;
            let mut args = Some((component_url, arguments));
            self.add_service((service_name, move |channel: fasync::Channel| {
                let res = (|| {
                    if let Some((component_url, arguments)) = args.take() {
                        launched_app = Some(
                            crate::client::Launcher::new()?.launch(component_url, arguments)?);
                    }
                    if let Some(app) = launched_app.as_ref() {
                        app.pass_to_named_service(service_name, channel.into())?;
                    }
                    Ok::<(), Error>(())
                })();
                if let Err(e) = res {
                    eprintln!("ServicesServer failed to launch component: {:?}", e);
                }
            }))
        }
pub fn add_component_proxy_service ( self , service_name : & ' static str , component_url : String , arguments : Option < Vec < String > > , ) -> Self { // Note: the launched app will live for the remaining lifetime of the // closure, which will be exactly as long as the lifetime of the resulting // `FdioServer`. When the `FdioServer` is dropped, the launched component // will be terminated. let mut launched_app = None ; let mut args = Some ( ( component_url , arguments ) ) ; self . add_service ( ( service_name , move | channel : fasync :: Channel | { let res = ( | | { if let Some ( ( component_url , arguments ) ) = args . take ( ) { launched_app = Some ( crate :: client :: Launcher :: new ( ) ? . launch ( component_url , arguments ) ? ) ; } if let Some ( app ) = launched_app . as_ref ( ) { app . pass_to_named_service ( service_name , channel . into ( ) ) ? ; } Ok :: < ( ) , Error > ( ( ) ) } ) ( ) ; if let Err ( e ) = res { eprintln ! ( " " e ) ; } } ) ) }
Add a service to the `ServicesServer` that will launch a component
upon request, proxying requests to the launched component.
Add a service to the ` ServicesServer ` that will launch a component upon request proxying requests to the launched component .
self
service_name
&'static str
component_url
String
arguments
Option<Vec<String>>