From 5a090f5e530440e2b4ebe40665a712bf9aa26a32 Mon Sep 17 00:00:00 2001 From: daladim Date: Sun, 21 Feb 2021 23:41:35 +0100 Subject: [PATCH] More debug functions to utils.rs --- src/data/client.rs | 5 +++-- src/utils.rs | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/data/client.rs b/src/data/client.rs index c26f727..25e447d 100644 --- a/src/data/client.rs +++ b/src/data/client.rs @@ -233,8 +233,7 @@ impl Client { let responses = find_elems(&el, "response"); for response in responses { - crate::print_xml(response); - println!("\n"); + println!("(a response)\n"); } Ok(()) @@ -265,5 +264,7 @@ mod test { calendars.iter() .map(|cal| println!(" {}", cal.name())) .collect::<()>(); + + client.get_tasks(&calendars[3].url()).await; } } diff --git a/src/utils.rs b/src/utils.rs index ff93203..fa80b76 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -36,4 +36,17 @@ pub fn find_elem>(root: &Element, searched_name: S) -> Option<&Ele } } None -} \ No newline at end of file +} + +pub fn print_xml(element: &Element) { + use std::io::Write; + let mut writer = std::io::stdout(); + + let mut xml_writer = minidom::quick_xml::Writer::new_with_indent( + std::io::stdout(), + 0x20, 4 + ); + element.to_writer(&mut xml_writer); + + writer.write(&[0x0a]); +}