aboutsummaryrefslogtreecommitdiffstats
path: root/examples/zot/network_stream.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/zot/network_stream.rs')
-rw-r--r--examples/zot/network_stream.rs29
1 files changed, 12 insertions, 17 deletions
diff --git a/examples/zot/network_stream.rs b/examples/zot/network_stream.rs
index de3b12f..6dc1a0c 100644
--- a/examples/zot/network_stream.rs
+++ b/examples/zot/network_stream.rs
@@ -25,11 +25,10 @@ pub fn fetch(client: &zotapi::Client, raw: bool) {
Ok(payload) => {
if raw {
println!("{}", payload);
- }
- else {
+ } else {
list(&payload);
}
- },
+ }
Err(e) => {
println!("Error getting channel stream: {:?}", e);
}
@@ -43,10 +42,8 @@ fn list(payload: &str) {
print_item(&item);
println!("-----");
}
- },
- Ok(_) => {
- println!("Wrong type returned, expected an array.")
- },
+ }
+ Ok(_) => println!("Wrong type returned, expected an array."),
Err(e) => {
println!("Error: {}", e);
}
@@ -76,8 +73,9 @@ fn get_object_type(item: &serde_json::Value) -> &str {
fn get_tags(item: &serde_json::Value) -> String {
match item["tags"] {
- serde_json::Value::Array(ref v) => {
- v.iter().map(|t| {
+ serde_json::Value::Array(ref v) => v
+ .iter()
+ .map(|t| {
let prefix = match get_str(&t["type"]) {
"hashtag" => "#",
"forum" => "!",
@@ -85,14 +83,11 @@ fn get_tags(item: &serde_json::Value) -> String {
_ => "",
};
format!("{}{}", prefix, get_str(&t["tag"]))
- }).collect::<Vec<_>>().join(", ")
- },
- serde_json::Value::Null => {
- String::new()
- },
- _ => {
- String::from("invalid tags, expected array...")
- }
+ })
+ .collect::<Vec<_>>()
+ .join(", "),
+ serde_json::Value::Null => String::new(),
+ _ => String::from("invalid tags, expected array..."),
}
}