async fn add_child_realm(
        &mut self,
        realm: &Realm,
        child: &ChildDecl,
        collection: Option<String>,
    ) -> Option<Arc<Realm>> {
        let instance_id = match collection {
            Some(_) => {
                let id = self.next_dynamic_instance_id;
                self.next_dynamic_instance_id += 1;
                id
            }
            None => 0,
        };
        let child_moniker = ChildMoniker::new(child.name.clone(), collection.clone(), instance_id);
        let partial_moniker = child_moniker.to_partial();
        if self.get_live_child_realm(&partial_moniker).is_none() {
            let abs_moniker = realm.abs_moniker.child(child_moniker.clone());
            let child_realm = Arc::new(Realm {
                resolver_registry: realm.resolver_registry.clone(),
                abs_moniker: abs_moniker,
                component_url: child.url.clone(),
                startup: child.startup,
                state: Mutex::new(None),
                execution: Mutex::new(ExecutionState::new()),
                actions: Mutex::new(ActionSet::new()),
                hooks: Hooks::new(Some(&realm.hooks)),
            });
            self.child_realms.insert(child_moniker, child_realm.clone());
            self.live_child_realms.insert(partial_moniker, (instance_id, child_realm.clone()));
            Some(child_realm)
        } else {
            None
        }
    }
/// Adds a new child of this realm for the given `ChildDecl`. Returns the child realm,
/// or None if it already existed.
Adds a new child of this realm for the given `ChildDecl`. Returns the child realm,
or None if it already existed.
Adds a new child of this realm for the given ` ChildDecl ` . Returns the child realm or None if it already existed .
async fn add_child_realm(
        &mut self,
        realm: &Realm,
        child: &ChildDecl,
        collection: Option<String>,
    ) -> Option<Arc<Realm>> {
        let instance_id = match collection {
            Some(_) => {
                let id = self.next_dynamic_instance_id;
                self.next_dynamic_instance_id += 1;
                id
            }
            None => 0,
        };
        let child_moniker = ChildMoniker::new(child.name.clone(), collection.clone(), instance_id);
        let partial_moniker = child_moniker.to_partial();
        if self.get_live_child_realm(&partial_moniker).is_none() {
            let abs_moniker = realm.abs_moniker.child(child_moniker.clone());
            let child_realm = Arc::new(Realm {
                resolver_registry: realm.resolver_registry.clone(),
                abs_moniker: abs_moniker,
                component_url: child.url.clone(),
                startup: child.startup,
                state: Mutex::new(None),
                execution: Mutex::new(ExecutionState::new()),
                actions: Mutex::new(ActionSet::new()),
                hooks: Hooks::new(Some(&realm.hooks)),
            });
            self.child_realms.insert(child_moniker, child_realm.clone());
            self.live_child_realms.insert(partial_moniker, (instance_id, child_realm.clone()));
            Some(child_realm)
        } else {
            None
        }
    }
async fn add_child_realm ( & mut self , realm : & Realm , child : & ChildDecl , collection : Option < String > , ) -> Option < Arc < Realm > > { let instance_id = match collection { Some ( _ ) => { let id = self . next_dynamic_instance_id ; self . next_dynamic_instance_id += 1 ; id } None => 0 , } ; let child_moniker = ChildMoniker :: new ( child . name . clone ( ) , collection . clone ( ) , instance_id ) ; let partial_moniker = child_moniker . to_partial ( ) ; if self . get_live_child_realm ( & partial_moniker ) . is_none ( ) { let abs_moniker = realm . abs_moniker . child ( child_moniker . clone ( ) ) ; let child_realm = Arc :: new ( Realm { resolver_registry : realm . resolver_registry . clone ( ) , abs_moniker : abs_moniker , component_url : child . url . clone ( ) , startup : child . startup , state : Mutex :: new ( None ) , execution : Mutex :: new ( ExecutionState :: new ( ) ) , actions : Mutex :: new ( ActionSet :: new ( ) ) , hooks : Hooks :: new ( Some ( & realm . hooks ) ) , } ) ; self . child_realms . insert ( child_moniker , child_realm . clone ( ) ) ; self . live_child_realms . insert ( partial_moniker , ( instance_id , child_realm . clone ( ) ) ) ; Some ( child_realm ) } else { None } }
Adds a new child of this realm for the given `ChildDecl`.
Adds a new child of this realm for the given ` ChildDecl ` .
&mut self
realm
&Realm
child
&ChildDecl
collection
Option<String>