Port forward tree iterator from python to rust.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use tokio::process::Child;
|
||||
use tracing::error;
|
||||
|
||||
@@ -5,6 +7,7 @@ use crate::Result;
|
||||
use crate::nix_util::NixOutputStream;
|
||||
use crate::nix_util::nix_output_stream::NixAction;
|
||||
use crate::nix_util::output_stream::OutputStream;
|
||||
use crate::nix_util::tree_iter::ForwardTreeIter;
|
||||
|
||||
use super::activity_tree::ActivityId;
|
||||
use super::activity_tree::ActivityTreeEntry;
|
||||
@@ -113,26 +116,21 @@ impl RunningUpdate {
|
||||
fn maybe_print_current_status(&mut self) -> () {}
|
||||
|
||||
fn print_current_status(&mut self) -> () {
|
||||
let nodes = self.get_children_in_order(self.activity_tree.get_tree().get_root_id());
|
||||
let nodes = ForwardTreeIter::new(
|
||||
self.activity_tree.get_tree(),
|
||||
None,
|
||||
|entry| true,
|
||||
|entry| false,
|
||||
|entry| true,
|
||||
);
|
||||
println!("\n\n\nvvvvvv\n\n");
|
||||
for n in nodes {
|
||||
let activity = n.get_activity();
|
||||
// if activity.is_active() {
|
||||
println!("{:?}", activity.display_name());
|
||||
// }
|
||||
for (depth, is_match, is_transparent, node) in nodes {
|
||||
let name = node
|
||||
.get_activity()
|
||||
.display_name()
|
||||
.unwrap_or(Cow::Borrowed("null"));
|
||||
println!("{depth}\t{is_match}\t{is_transparent}\t{name}");
|
||||
}
|
||||
println!("\n\n\n^^^^^^\n\n");
|
||||
}
|
||||
|
||||
fn get_children_in_order(
|
||||
&self,
|
||||
parent_id: ActivityId,
|
||||
) -> impl Iterator<Item = &ActivityTreeEntry> {
|
||||
let parent = self.activity_tree.get_tree().get(&parent_id);
|
||||
parent
|
||||
.get_child_ids()
|
||||
.iter()
|
||||
.map(|child_id| self.activity_tree.get_tree().get(child_id))
|
||||
.flat_map(|child| TransparentIter::new(self.activity_tree.get_tree(), child))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user