async fn route_instance(
        &self,
        instance: &str,
    ) -> Result<CapabilitySourceInterface<C>, RoutingError> {
        let collection_component = self.collection_component.upgrade()?;
        let (child_moniker, child_component): (ChildMoniker, Arc<C>) = {
            collection_component
                .lock_resolved_state()
                .await?
                .live_children_in_collection(&self.collection_name)
                .into_iter()
                .find_map(move |(m, c)| if m.name() == instance { Some((m, c)) } else { None })
                .ok_or_else(|| RoutingError::OfferFromChildInstanceNotFound {
                    child_moniker: ChildMoniker::new(
                        instance.to_string(),
                        Some(self.collection_name.clone()),
                    ),
                    moniker: collection_component.abs_moniker().clone(),
                    capability_id: self.target_decl.source_name().clone().into(),
                })?
        };

        let expose_decl: E = {
            let child_exposes = child_component.lock_resolved_state().await?.exposes();
            find_matching_expose(self.target_decl.source_name(), &child_exposes)
                .cloned()
                .ok_or_else(|| {
                    E::error_not_found_in_child(
                        collection_component.abs_moniker().clone(),
                        child_moniker,
                        self.target_decl.source_name().clone(),
                    )
                })?
        };
        self.router
            .route_from_expose(
                expose_decl,
                child_component,
                self.sources.clone(),
                &mut self.visitor.clone(),
                &mut self.mapper.clone(),
            )
            .await
    }
/// Returns a `CapabilitySourceInterface` to a service capability exposed by a child.
///
/// `instance` is the name of the child that exposes the service, as returned by
/// `list_instances`.
Returns a `CapabilitySourceInterface` to a service capability exposed by a child.
`instance` is the name of the child that exposes the service, as returned by
`list_instances`.
Returns a ` CapabilitySourceInterface ` to a service capability exposed by a child . ` instance ` is the name of the child that exposes the service as returned by ` list_instances ` .
async fn route_instance(
        &self,
        instance: &str,
    ) -> Result<CapabilitySourceInterface<C>, RoutingError> {
        let collection_component = self.collection_component.upgrade()?;
        let (child_moniker, child_component): (ChildMoniker, Arc<C>) = {
            collection_component
                .lock_resolved_state()
                .await?
                .live_children_in_collection(&self.collection_name)
                .into_iter()
                .find_map(move |(m, c)| if m.name() == instance { Some((m, c)) } else { None })
                .ok_or_else(|| RoutingError::OfferFromChildInstanceNotFound {
                    child_moniker: ChildMoniker::new(
                        instance.to_string(),
                        Some(self.collection_name.clone()),
                    ),
                    moniker: collection_component.abs_moniker().clone(),
                    capability_id: self.target_decl.source_name().clone().into(),
                })?
        };
        let expose_decl: E = {
            let child_exposes = child_component.lock_resolved_state().await?.exposes();
            find_matching_expose(self.target_decl.source_name(), &child_exposes)
                .cloned()
                .ok_or_else(|| {
                    E::error_not_found_in_child(
                        collection_component.abs_moniker().clone(),
                        child_moniker,
                        self.target_decl.source_name().clone(),
                    )
                })?
        };
        self.router
            .route_from_expose(
                expose_decl,
                child_component,
                self.sources.clone(),
                &mut self.visitor.clone(),
                &mut self.mapper.clone(),
            )
            .await
    }
async fn route_instance ( & self , instance : & str , ) -> Result < CapabilitySourceInterface < C > , RoutingError > { let collection_component = self . collection_component . upgrade ( ) ? ; let ( child_moniker , child_component ) : ( ChildMoniker , Arc < C > ) = { collection_component . lock_resolved_state ( ) . await ? . live_children_in_collection ( & self . collection_name ) . into_iter ( ) . find_map ( move | ( m , c ) | if m . name ( ) == instance { Some ( ( m , c ) ) } else { None } ) . ok_or_else ( | | RoutingError :: OfferFromChildInstanceNotFound { child_moniker : ChildMoniker :: new ( instance . to_string ( ) , Some ( self . collection_name . clone ( ) ) , ) , moniker : collection_component . abs_moniker ( ) . clone ( ) , capability_id : self . target_decl . source_name ( ) . clone ( ) . into ( ) , } ) ? } ; let expose_decl : E = { let child_exposes = child_component . lock_resolved_state ( ) . await ? . exposes ( ) ; find_matching_expose ( self . target_decl . source_name ( ) , & child_exposes ) . cloned ( ) . ok_or_else ( | | { E :: error_not_found_in_child ( collection_component . abs_moniker ( ) . clone ( ) , child_moniker , self . target_decl . source_name ( ) . clone ( ) , ) } ) ? } ; self . router . route_from_expose ( expose_decl , child_component , self . sources . clone ( ) , & mut self . visitor . clone ( ) , & mut self . mapper . clone ( ) , ) . await }
Returns a `CapabilitySourceInterface` to a service capability exposed by a child.
Returns a ` CapabilitySourceInterface ` to a service capability exposed by a child .
&self
instance
&str
&self
instance
&str