From 7bfb5f8bae9b085e5b307526806d64c9d73c666e Mon Sep 17 00:00:00 2001 From: tupshin Date: Fri, 31 Jan 2020 12:54:20 -0500 Subject: [PATCH 1/2] add a public get_tree() method and have print_tree use it Note that I found this useful when debugging and I didn't have access to a normal stdout. --- src/system/system.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/system/system.rs b/src/system/system.rs index d00f019c..4bf278bc 100644 --- a/src/system/system.rs +++ b/src/system/system.rs @@ -239,24 +239,35 @@ impl ActorSystem { } pub fn print_tree(&self) { - fn print_node(sys: &ActorSystem, node: BasicActorRef, indent: &str) { + println!("{}", self.get_tree()); + } + + pub fn get_tree(&self) -> String { + let mut tree_str: String = String::new(); + fn get_node( + mut tree_str: &mut String, + sys: &ActorSystem, + node: BasicActorRef, + indent: &str, + ) -> String { if node.is_root() { - println!("{}", sys.name()); + tree_str.push_str(&mut format!("{}\n", sys.name())); for actor in node.children() { - print_node(sys, actor, ""); + get_node(&mut tree_str, sys, actor, ""); } } else { - println!("{}└─ {}", indent, node.name()); + tree_str.push_str(&mut format!("{}└─ {}\n", indent, node.name())); for actor in node.children() { - print_node(sys, actor, &(indent.to_string() + " ")); + get_node(tree_str, sys, actor, &(indent.to_string() + " ")); } } + tree_str.to_string() } let root = self.sys_actors.as_ref().unwrap().root.clone(); - print_node(self, root, ""); + get_node(&mut tree_str, self, root, "") } /// Returns the system root's actor reference From fda28c67cca9037994630b3766c1408a05fa5fee Mon Sep 17 00:00:00 2001 From: tupshin Date: Mon, 10 Feb 2020 17:26:44 -0500 Subject: [PATCH 2/2] updated to use the latest config crate --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b3df1006..fbe7be11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ travis-ci = { repository = "riker-rs/riker" } riker-macros = { path = "riker-macros", version = "0.1" } bytes = "0.4" chrono = "0.4" -config = "0.9" +config = "0.10.1" futures-preview = "0.3.0-alpha.16" log = { version = "0.4", features = ["std"] } rand = "0.4"