pub async fn create_child_component(
    url: String,
    args: fcomponent::CreateChildArgs,
) -> Result<(), Error> {
    // TODO(fxbug.dev/74511): The amount of setup required here is a bit lengthy. Ideally,
    // fuchsia-component would provide language-specific bindings for the Realm API that could
    // reduce this logic to a few lines.

    const COLLECTION: &str = "playground";
    let realm = fclient::realm().context("failed to connect to Realm service")?;
    let mut collection_ref = fdecl::CollectionRef { name: COLLECTION.into() };
    let id: u64 = rand::thread_rng().gen();
    let child_name = format!("starnix-{}", id);
    let child_decl = fdecl::Child {
        name: Some(child_name.clone()),
        url: Some(url),
        startup: Some(fdecl::StartupMode::Lazy),
        environment: None,
        ..fdecl::Child::EMPTY
    };
    let () = realm
        .create_child(&mut collection_ref, child_decl, args)
        .await?
        .map_err(|e| format_err!("failed to create child: {:?}", e))?;
    // The component is run in a `SingleRun` collection instance, and will be automatically
    // deleted when it exits.
    Ok(())
}
/// Creates a new child component in the `playground` collection.
///
/// # Parameters
/// - `url`: The URL of the component to create.
/// - `args`: The `CreateChildArgs` that are passed to the component manager.
Creates a new child component in the `playground` collection.
Creates a new child component in the ` playground ` collection .
pub async fn create_child_component(
    url: String,
    args: fcomponent::CreateChildArgs,
) -> Result<(), Error> {
    // TODO(fxbug.dev/74511): The amount of setup required here is a bit lengthy. Ideally,
    // fuchsia-component would provide language-specific bindings for the Realm API that could
    // reduce this logic to a few lines.
    const COLLECTION: &str = "playground";
    let realm = fclient::realm().context("failed to connect to Realm service")?;
    let mut collection_ref = fdecl::CollectionRef { name: COLLECTION.into() };
    let id: u64 = rand::thread_rng().gen();
    let child_name = format!("starnix-{}", id);
    let child_decl = fdecl::Child {
        name: Some(child_name.clone()),
        url: Some(url),
        startup: Some(fdecl::StartupMode::Lazy),
        environment: None,
        ..fdecl::Child::EMPTY
    };
    let () = realm
        .create_child(&mut collection_ref, child_decl, args)
        .await?
        .map_err(|e| format_err!("failed to create child: {:?}", e))?;
    // The component is run in a `SingleRun` collection instance, and will be automatically
    // deleted when it exits.
    Ok(())
}
pub async fn create_child_component ( url : String , args : fcomponent :: CreateChildArgs , ) -> Result < ( ) , Error > { // TODO(fxbug.dev/74511): The amount of setup required here is a bit lengthy. Ideally, // fuchsia-component would provide language-specific bindings for the Realm API that could // reduce this logic to a few lines. const COLLECTION : & str = " " ; let realm = fclient :: realm ( ) . context ( " " ) ? ; let mut collection_ref = fdecl :: CollectionRef { name : COLLECTION . into ( ) } ; let id : u64 = rand :: thread_rng ( ) . gen ( ) ; let child_name = format ! ( " " id ) ; let child_decl = fdecl :: Child { name : Some ( child_name . clone ( ) ) , url : Some ( url ) , startup : Some ( fdecl :: StartupMode :: Lazy ) , environment : None , .. fdecl :: Child :: EMPTY } ; let ( ) = realm . create_child ( & mut collection_ref , child_decl , args ) . await ? . map_err ( | e | format_err ! ( " " e ) ) ? ; // The component is run in a `SingleRun` collection instance, and will be automatically // deleted when it exits. Ok ( ( ) ) }
Creates a new child component in the `playground` collection.
Creates a new child component in the ` playground ` collection .
url
String
args
fcomponent::CreateChildArgs
url
String
The URL of the component to create.
The URL of the component to create .
args
fcomponent::CreateChildArgs
The `CreateChildArgs` that are passed to the component manager.
The ` CreateChildArgs ` that are passed to the component manager .