pub(super) async fn add_clone_cell_to_app(
        &mut self,
        installed_app_id: &InstalledAppId,
        slot_id: &SlotId,
        properties: YamlProperties,
    ) -> ConductorResult<CellId> {
        let saf_store = &self.saf_store;
        let (_, child_saf) = self
            .update_state_prime(move |mut state| {
                if let Some(app) = state.active_apps.get_mut(installed_app_id) {
                    let slot = app
                        .slots()
                        .get(slot_id)
                        .ok_or_else(|| AppError::SlotIdMissing(slot_id.to_owned()))?;
                    let parent_saf_hash = slot.saf_hash();
                    let saf = saf_store
                        .get(parent_saf_hash)
                        .ok_or_else(|| SafError::SafMissing(parent_saf_hash.to_owned()))?
                        .modify_phenotype(random_uid(), properties)?;
                    Ok((state, saf))
                } else {
                    Err(ConductorError::AppNotActive(installed_app_id.clone()))
                }
            })
            .await?;
        let child_saf_hash = child_saf.saf_hash().to_owned();
        self.register_phenotype(child_saf).await?;
        let (_, cell_id) = self
            .update_state_prime(|mut state| {
                if let Some(app) = state.active_apps.get_mut(installed_app_id) {
                    let agent_key = app.slot(slot_id)?.agent_key().to_owned();
                    let cell_id = CellId::new(child_saf_hash, agent_key);
                    app.add_clone(slot_id, cell_id.clone())?;
                    Ok((state, cell_id))
                } else {
                    Err(ConductorError::AppNotActive(installed_app_id.clone()))
                }
            })
            .await?;
        Ok(cell_id)
    }
/// Associate a Cell with an existing App
Associate a Cell with an existing App
Associate a Cell with an existing App
pub(super) async fn add_clone_cell_to_app(
        &mut self,
        installed_app_id: &InstalledAppId,
        slot_id: &SlotId,
        properties: YamlProperties,
    ) -> ConductorResult<CellId> {
        let saf_store = &self.saf_store;
        let (_, child_saf) = self
            .update_state_prime(move |mut state| {
                if let Some(app) = state.active_apps.get_mut(installed_app_id) {
                    let slot = app
                        .slots()
                        .get(slot_id)
                        .ok_or_else(|| AppError::SlotIdMissing(slot_id.to_owned()))?;
                    let parent_saf_hash = slot.saf_hash();
                    let saf = saf_store
                        .get(parent_saf_hash)
                        .ok_or_else(|| SafError::SafMissing(parent_saf_hash.to_owned()))?
                        .modify_phenotype(random_uid(), properties)?;
                    Ok((state, saf))
                } else {
                    Err(ConductorError::AppNotActive(installed_app_id.clone()))
                }
            })
            .await?;
        let child_saf_hash = child_saf.saf_hash().to_owned();
        self.register_phenotype(child_saf).await?;
        let (_, cell_id) = self
            .update_state_prime(|mut state| {
                if let Some(app) = state.active_apps.get_mut(installed_app_id) {
                    let agent_key = app.slot(slot_id)?.agent_key().to_owned();
                    let cell_id = CellId::new(child_saf_hash, agent_key);
                    app.add_clone(slot_id, cell_id.clone())?;
                    Ok((state, cell_id))
                } else {
                    Err(ConductorError::AppNotActive(installed_app_id.clone()))
                }
            })
            .await?;
        Ok(cell_id)
    }
pub ( super ) async fn add_clone_cell_to_app ( & mut self , installed_app_id : & InstalledAppId , slot_id : & SlotId , properties : YamlProperties , ) -> ConductorResult < CellId > { let saf_store = & self . saf_store ; let ( _ , child_saf ) = self . update_state_prime ( move | mut state | { if let Some ( app ) = state . active_apps . get_mut ( installed_app_id ) { let slot = app . slots ( ) . get ( slot_id ) . ok_or_else ( | | AppError :: SlotIdMissing ( slot_id . to_owned ( ) ) ) ? ; let parent_saf_hash = slot . saf_hash ( ) ; let saf = saf_store . get ( parent_saf_hash ) . ok_or_else ( | | SafError :: SafMissing ( parent_saf_hash . to_owned ( ) ) ) ? . modify_phenotype ( random_uid ( ) , properties ) ? ; Ok ( ( state , saf ) ) } else { Err ( ConductorError :: AppNotActive ( installed_app_id . clone ( ) ) ) } } ) . await ? ; let child_saf_hash = child_saf . saf_hash ( ) . to_owned ( ) ; self . register_phenotype ( child_saf ) . await ? ; let ( _ , cell_id ) = self . update_state_prime ( | mut state | { if let Some ( app ) = state . active_apps . get_mut ( installed_app_id ) { let agent_key = app . slot ( slot_id ) ? . agent_key ( ) . to_owned ( ) ; let cell_id = CellId :: new ( child_saf_hash , agent_key ) ; app . add_clone ( slot_id , cell_id . clone ( ) ) ? ; Ok ( ( state , cell_id ) ) } else { Err ( ConductorError :: AppNotActive ( installed_app_id . clone ( ) ) ) } } ) . await ? ; Ok ( cell_id ) }
Associate a Cell with an existing App
Associate a Cell with an existing App
&mut self
installed_app_id
&InstalledAppId
slot_id
&SlotId
properties
YamlProperties
&mut self
installed_app_id
&InstalledAppId
slot_id
&SlotId
properties
YamlProperties