/// Creates a child in the specified `Realm`.
///
/// # Parameters
/// - `child_name`: The name of the child to be added.
/// - `child_url`: The component URL of the child to add.
/// - `collection_name`: The name of the collection to which the child will be added.
/// - `realm`: The `Realm` to which the child will be added.
///
/// # Returns
/// `Ok` if the child is created successfully.
Creates a child in the specified `Realm`.
Creates a child in the specified ` Realm ` .
pub async fn create_child_component(
    child_name: &str,
    child_url: &str,
    collection_name: &str,
    realm: &fcomponent::RealmProxy,
) -> Result<(), fcomponent::Error> {
    let mut collection_ref = fdecl::CollectionRef { name: collection_name.to_string() };
    let child_decl = fdecl::Child {
        name: Some(child_name.to_string()),
        url: Some(child_url.to_string()),
        startup: Some(fdecl::StartupMode::Lazy), // Dynamic children can only be started lazily.
        environment: None,
        ..fdecl::Child::EMPTY
    };
    let child_args = fcomponent::CreateChildArgs {
        numbered_handles: None,
        ..fcomponent::CreateChildArgs::EMPTY
    };
    realm
        .create_child(&mut collection_ref, child_decl, child_args)
        .await
        .map_err(|_| fcomponent::Error::Internal)??;
    Ok(())
}
pub async fn create_child_component ( child_name : & str , child_url : & str , collection_name : & str , realm : & fcomponent :: RealmProxy , ) -> Result < ( ) , fcomponent :: Error > { let mut collection_ref = fdecl :: CollectionRef { name : collection_name . to_string ( ) } ; let child_decl = fdecl :: Child { name : Some ( child_name . to_string ( ) ) , url : Some ( child_url . to_string ( ) ) , startup : Some ( fdecl :: StartupMode :: Lazy ) , // Dynamic children can only be started lazily. environment : None , .. fdecl :: Child :: EMPTY } ; let child_args = fcomponent :: CreateChildArgs { numbered_handles : None , .. fcomponent :: CreateChildArgs :: EMPTY } ; realm . create_child ( & mut collection_ref , child_decl , child_args ) . await . map_err ( | _ | fcomponent :: Error :: Internal ) ? ? ; Ok ( ( ) ) }
Creates a child in the specified `Realm`.
Creates a child in the specified ` Realm ` .
`Ok` if the child is created successfully.
` Ok ` if the child is created successfully .
child_name
&str
The name of the child to be added.
The name of the child to be added .
child_url
&str
The component URL of the child to add.
The component URL of the child to add .
collection_name
&str
The name of the collection to which the child will be added.
The name of the collection to which the child will be added .
realm
&fcomponent::RealmProxy
The `Realm` to which the child will be added.
The ` Realm ` to which the child will be added .