pub async fn resolve_meta_dir(
        &self,
        model: &Model,
    ) -> Result<Option<Arc<DirectoryProxy>>, ModelError> {
        {
            // If our meta directory has already been resolved, just return the answer.
            let state = self.lock_state().await;
            let state = state.as_ref().expect("resolve_meta_dir: not resolved");
            if state.meta_dir.is_some() {
                return Ok(Some(state.meta_dir.as_ref().unwrap().clone()));
            }

            // If we don't even have a meta directory, return None.
            if !state.decl().uses.iter().any(|u| u == &UseDecl::Storage(UseStorageDecl::Meta)) {
                return Ok(None);
            }

            // Don't hold the state lock while performing routing for the meta storage capability,
            // as the routing logic may want to acquire the lock for this component's state.
        }

        let (meta_client_chan, server_chan) =
            zx::Channel::create().expect("failed to create channel");

        routing::route_and_open_storage_capability(
            &model,
            &UseStorageDecl::Meta,
            MODE_TYPE_DIRECTORY,
            self.abs_moniker.clone(),
            server_chan,
        )
        .await?;
        let meta_dir = Arc::new(DirectoryProxy::from_channel(
            fasync::Channel::from_channel(meta_client_chan).unwrap(),
        ));

        let mut state = self.lock_state().await;
        let state = state.as_mut().expect("resolve_meta_dir: not resolved");
        state.meta_dir = Some(meta_dir.clone());
        Ok(Some(meta_dir))
    }
/// Resolves and populates this component's meta directory handle if it has not been done so
/// already, and returns a reference to the handle. If this component does not use meta storage
/// Ok(None) will be returned.
Resolves and populates this component's meta directory handle if it has not been done so
already, and returns a reference to the handle. If this component does not use meta storage
Ok(None) will be returned.
Resolves and populates this component ' s meta directory handle if it has not been done so already and returns a reference to the handle . If this component does not use meta storage Ok ( None ) will be returned .
pub async fn resolve_meta_dir(
        &self,
        model: &Model,
    ) -> Result<Option<Arc<DirectoryProxy>>, ModelError> {
        {
            // If our meta directory has already been resolved, just return the answer.
            let state = self.lock_state().await;
            let state = state.as_ref().expect("resolve_meta_dir: not resolved");
            if state.meta_dir.is_some() {
                return Ok(Some(state.meta_dir.as_ref().unwrap().clone()));
            }
            // If we don't even have a meta directory, return None.
            if !state.decl().uses.iter().any(|u| u == &UseDecl::Storage(UseStorageDecl::Meta)) {
                return Ok(None);
            }
            // Don't hold the state lock while performing routing for the meta storage capability,
            // as the routing logic may want to acquire the lock for this component's state.
        }
        let (meta_client_chan, server_chan) =
            zx::Channel::create().expect("failed to create channel");
        routing::route_and_open_storage_capability(
            &model,
            &UseStorageDecl::Meta,
            MODE_TYPE_DIRECTORY,
            self.abs_moniker.clone(),
            server_chan,
        )
        .await?;
        let meta_dir = Arc::new(DirectoryProxy::from_channel(
            fasync::Channel::from_channel(meta_client_chan).unwrap(),
        ));
        let mut state = self.lock_state().await;
        let state = state.as_mut().expect("resolve_meta_dir: not resolved");
        state.meta_dir = Some(meta_dir.clone());
        Ok(Some(meta_dir))
    }
pub async fn resolve_meta_dir ( & self , model : & Model , ) -> Result < Option < Arc < DirectoryProxy > > , ModelError > { { // If our meta directory has already been resolved, just return the answer. let state = self . lock_state ( ) . await ; let state = state . as_ref ( ) . expect ( " " ) ; if state . meta_dir . is_some ( ) { return Ok ( Some ( state . meta_dir . as_ref ( ) . unwrap ( ) . clone ( ) ) ) ; } // If we don't even have a meta directory, return None. if ! state . decl ( ) . uses . iter ( ) . any ( | u | u == & UseDecl :: Storage ( UseStorageDecl :: Meta ) ) { return Ok ( None ) ; } // Don't hold the state lock while performing routing for the meta storage capability, // as the routing logic may want to acquire the lock for this component's state. } let ( meta_client_chan , server_chan ) = zx :: Channel :: create ( ) . expect ( " " ) ; routing :: route_and_open_storage_capability ( & model , & UseStorageDecl :: Meta , MODE_TYPE_DIRECTORY , self . abs_moniker . clone ( ) , server_chan , ) . await ? ; let meta_dir = Arc :: new ( DirectoryProxy :: from_channel ( fasync :: Channel :: from_channel ( meta_client_chan ) . unwrap ( ) , ) ) ; let mut state = self . lock_state ( ) . await ; let state = state . as_mut ( ) . expect ( " " ) ; state . meta_dir = Some ( meta_dir . clone ( ) ) ; Ok ( Some ( meta_dir ) ) }
Resolves and populates this component's meta directory handle if it has not been done so
already, and returns a reference to the handle.
Resolves and populates this component ' s meta directory handle if it has not been done so already and returns a reference to the handle .
&self
model
&Model