async fn make_execution_runtime(
    realm: WeakRealm,
    url: String,
    package: Option<fsys::Package>,
    decl: &cm_rust::ComponentDecl,
) -> Result<
    (Runtime, fcrunner::ComponentStartInfo, ServerEnd<fcrunner::ComponentControllerMarker>),
    ModelError,
> {
    // Create incoming/outgoing directories, and populate them.
    let exposed_dir = ExposedDir::new(
        ExecutionScope::from_executor(Box::new(EHandle::local())),
        realm.clone(),
        decl.clone(),
    )?;
    let (outgoing_dir_client, outgoing_dir_server) =
        zx::Channel::create().map_err(|e| ModelError::namespace_creation_failed(e))?;
    let (runtime_dir_client, runtime_dir_server) =
        zx::Channel::create().map_err(|e| ModelError::namespace_creation_failed(e))?;
    let mut namespace = IncomingNamespace::new(package)?;
    let ns = namespace.populate(realm, decl).await?;

    let (controller_client, controller_server) =
        endpoints::create_endpoints::<fcrunner::ComponentControllerMarker>()
            .expect("could not create component controller endpoints");
    let controller =
        controller_client.into_proxy().expect("failed to create ComponentControllerProxy");
    // Set up channels into/out of the new component.
    let runtime = Runtime::start_from(
        url.clone(),
        Some(namespace),
        Some(DirectoryProxy::from_channel(
            fasync::Channel::from_channel(outgoing_dir_client).unwrap(),
        )),
        Some(DirectoryProxy::from_channel(
            fasync::Channel::from_channel(runtime_dir_client).unwrap(),
        )),
        exposed_dir,
        Some(controller),
    )?;
    let start_info = fcrunner::ComponentStartInfo {
        resolved_url: Some(url),
        program: data::clone_option_dictionary(&decl.program),
        ns: Some(ns),
        outgoing_dir: Some(ServerEnd::new(outgoing_dir_server)),
        runtime_dir: Some(ServerEnd::new(runtime_dir_server)),
    };

    Ok((runtime, start_info, controller_server))
}
/// Returns a configured Runtime for a component and the start info (without actually starting
/// the component).
Returns a configured Runtime for a component and the start info (without actually starting
the component).
Returns a configured Runtime for a component and the start info ( without actually starting the component ) .
async fn make_execution_runtime(
    realm: WeakRealm,
    url: String,
    package: Option<fsys::Package>,
    decl: &cm_rust::ComponentDecl,
) -> Result<
    (Runtime, fcrunner::ComponentStartInfo, ServerEnd<fcrunner::ComponentControllerMarker>),
    ModelError,
> {
    // Create incoming/outgoing directories, and populate them.
    let exposed_dir = ExposedDir::new(
        ExecutionScope::from_executor(Box::new(EHandle::local())),
        realm.clone(),
        decl.clone(),
    )?;
    let (outgoing_dir_client, outgoing_dir_server) =
        zx::Channel::create().map_err(|e| ModelError::namespace_creation_failed(e))?;
    let (runtime_dir_client, runtime_dir_server) =
        zx::Channel::create().map_err(|e| ModelError::namespace_creation_failed(e))?;
    let mut namespace = IncomingNamespace::new(package)?;
    let ns = namespace.populate(realm, decl).await?;
    let (controller_client, controller_server) =
        endpoints::create_endpoints::<fcrunner::ComponentControllerMarker>()
            .expect("could not create component controller endpoints");
    let controller =
        controller_client.into_proxy().expect("failed to create ComponentControllerProxy");
    // Set up channels into/out of the new component.
    let runtime = Runtime::start_from(
        url.clone(),
        Some(namespace),
        Some(DirectoryProxy::from_channel(
            fasync::Channel::from_channel(outgoing_dir_client).unwrap(),
        )),
        Some(DirectoryProxy::from_channel(
            fasync::Channel::from_channel(runtime_dir_client).unwrap(),
        )),
        exposed_dir,
        Some(controller),
    )?;
    let start_info = fcrunner::ComponentStartInfo {
        resolved_url: Some(url),
        program: data::clone_option_dictionary(&decl.program),
        ns: Some(ns),
        outgoing_dir: Some(ServerEnd::new(outgoing_dir_server)),
        runtime_dir: Some(ServerEnd::new(runtime_dir_server)),
    };
    Ok((runtime, start_info, controller_server))
}
async fn make_execution_runtime ( realm : WeakRealm , url : String , package : Option < fsys :: Package > , decl : & cm_rust :: ComponentDecl , ) -> Result < ( Runtime , fcrunner :: ComponentStartInfo , ServerEnd < fcrunner :: ComponentControllerMarker > ) , ModelError , > { // Create incoming/outgoing directories, and populate them. let exposed_dir = ExposedDir :: new ( ExecutionScope :: from_executor ( Box :: new ( EHandle :: local ( ) ) ) , realm . clone ( ) , decl . clone ( ) , ) ? ; let ( outgoing_dir_client , outgoing_dir_server ) = zx :: Channel :: create ( ) . map_err ( | e | ModelError :: namespace_creation_failed ( e ) ) ? ; let ( runtime_dir_client , runtime_dir_server ) = zx :: Channel :: create ( ) . map_err ( | e | ModelError :: namespace_creation_failed ( e ) ) ? ; let mut namespace = IncomingNamespace :: new ( package ) ? ; let ns = namespace . populate ( realm , decl ) . await ? ; let ( controller_client , controller_server ) = endpoints :: create_endpoints :: < fcrunner :: ComponentControllerMarker > ( ) . expect ( " " ) ; let controller = controller_client . into_proxy ( ) . expect ( " " ) ; // Set up channels into/out of the new component. let runtime = Runtime :: start_from ( url . clone ( ) , Some ( namespace ) , Some ( DirectoryProxy :: from_channel ( fasync :: Channel :: from_channel ( outgoing_dir_client ) . unwrap ( ) , ) ) , Some ( DirectoryProxy :: from_channel ( fasync :: Channel :: from_channel ( runtime_dir_client ) . unwrap ( ) , ) ) , exposed_dir , Some ( controller ) , ) ? ; let start_info = fcrunner :: ComponentStartInfo { resolved_url : Some ( url ) , program : data :: clone_option_dictionary ( & decl . program ) , ns : Some ( ns ) , outgoing_dir : Some ( ServerEnd :: new ( outgoing_dir_server ) ) , runtime_dir : Some ( ServerEnd :: new ( runtime_dir_server ) ) , } ; Ok ( ( runtime , start_info , controller_server ) ) }
Returns a configured Runtime for a component and the start info (without actually starting
the component).
Returns a configured Runtime for a component and the start info ( without actually starting the component ) .
realm
WeakRealm
url
String
package
Option<fsys::Package>
decl
&cm_rust::ComponentDecl
realm
WeakRealm
url
String
package
Option<fsys::Package>
decl
&cm_rust::ComponentDecl