diff options
Diffstat (limited to 'examples/zot/group.rs')
-rw-r--r-- | examples/zot/group.rs | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/examples/zot/group.rs b/examples/zot/group.rs index e02fb13..9264cdc 100644 --- a/examples/zot/group.rs +++ b/examples/zot/group.rs @@ -15,11 +15,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -use serde_json::{Value, from_str}; +use serde_json::{from_str, Value}; pub fn list(data: &str) { if let Ok(Value::Array(groups)) = from_str(&data) { - println!("Id | Group name | uid | flags | hash"); println!("----+------------------+-----+-------+-------------------------"); @@ -38,34 +37,34 @@ pub fn list(data: &str) { } } - print!("{:>3} | {:16} | {:>3} | {:5} | {}\n", + print!( + "{:>3} | {:16} | {:>3} | {:5} | {}\n", group["id"].as_u64().unwrap(), group["gname"].as_str().unwrap(), group["uid"].as_u64().unwrap(), flags, - group["hash"].as_str().unwrap()); + group["hash"].as_str().unwrap() + ); } - } - else { + } else { eprintln!("Invalid data"); } } - pub fn list_members(data: &str) { if let Ok(Value::Array(members)) = from_str(&data) { - println!("Id | Name | Address"); println!("----+-------------------------------+------------------------"); for member in members { - println!("{:>3} | {:29} | {}", + println!( + "{:>3} | {:29} | {}", member["id"].as_u64().unwrap(), member["xchan_name"].as_str().unwrap(), - member["xchan_addr"].as_str().unwrap()); + member["xchan_addr"].as_str().unwrap() + ); } - } - else { + } else { eprintln!("Invalid data"); } } |