Port forward tree iterator from python to rust.

This commit is contained in:
Tom Alexander
2026-06-27 19:31:59 -04:00
parent fba8203cda
commit 1b09c77492
15 changed files with 862 additions and 25 deletions

View File

@@ -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))
}
}