/// Recursive helper method for parse that accumulates the ancestors of the component.
Recursive helper method for parse that accumulates the ancestors of the component.
Recursive helper method for parse that accumulates the ancestors of the component .
fn parse_recursive(
        name: String,
        hub_dir: Directory,
        ancestors: Vec<String>,
    ) -> BoxFuture<'static, Result<Component>> {
        async move {
            let is_running = hub_dir.exists("exec").await?;
            // Add this component to the list of ancestors for its children.
            let mut child_ancestors = ancestors.clone();
            child_ancestors.extend([name.clone()]);
            // Recurse on the CML children
            let mut future_children = vec![];
            let children_dir = hub_dir.open_dir_readable("children")?;
            for child_name in children_dir.entries().await? {
                let hub_dir = children_dir.open_dir_readable(&child_name)?;
                let future_child =
                    Component::parse_recursive(child_name, hub_dir, child_ancestors.clone());
                future_children.push(future_child);
            }
            let results = join_all(future_children).await;
            let mut children = vec![];
            for result in results {
                let component = result?;
                children.push(component);
            }
            if name == "appmgr" {
                // Get all CMX components + realms
                let realm_dir = hub_dir.open_dir_readable("exec/out/hub")?;
                let component =
                    Component::parse_cmx_realm("".to_string(), realm_dir, child_ancestors).await?;
                children.extend(component.children);
            }
            Ok(Component { name, children, is_cmx: false, is_running, ancestors: ancestors })
        }
        .boxed()
    }
fn parse_recursive ( name : String , hub_dir : Directory , ancestors : Vec < String > , ) -> BoxFuture < ' static , Result < Component > > { async move { let is_running = hub_dir . exists ( " " ) . await ? ; // Add this component to the list of ancestors for its children. let mut child_ancestors = ancestors . clone ( ) ; child_ancestors . extend ( [ name . clone ( ) ] ) ; // Recurse on the CML children let mut future_children = vec ! [ ] ; let children_dir = hub_dir . open_dir_readable ( " " ) ? ; for child_name in children_dir . entries ( ) . await ? { let hub_dir = children_dir . open_dir_readable ( & child_name ) ? ; let future_child = Component :: parse_recursive ( child_name , hub_dir , child_ancestors . clone ( ) ) ; future_children . push ( future_child ) ; } let results = join_all ( future_children ) . await ; let mut children = vec ! [ ] ; for result in results { let component = result ? ; children . push ( component ) ; } if name == " " { // Get all CMX components + realms let realm_dir = hub_dir . open_dir_readable ( " " ) ? ; let component = Component :: parse_cmx_realm ( " " . to_string ( ) , realm_dir , child_ancestors ) . await ? ; children . extend ( component . children ) ; } Ok ( Component { name , children , is_cmx : false , is_running , ancestors : ancestors } ) } . boxed ( ) }
Recursive helper method for parse that accumulates the ancestors of the component.
Recursive helper method for parse that accumulates the ancestors of the component .
name
String
hub_dir
Directory
ancestors
Vec<String>