diff --git a/Cargo.toml b/Cargo.toml index be841e9c..721b54c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ serde_json = "1.0" [dependencies.reqwest_] package = "reqwest" -version = "0.10" +version = "0.11" optional = true default-features = false features = ["gzip"] @@ -28,8 +28,8 @@ optional = true [dev-dependencies.tokio] package = "tokio" -version = "0.2" -features = ["macros"] +version = "1.2" +features = ["macros", "rt-multi-thread"] [features] default = ["reqwest", "with_native_tls"] diff --git a/src/async_impl/mods/api.rs b/src/async_impl/mods/api.rs index 4a4cf0da..9b375a78 100644 --- a/src/async_impl/mods/api.rs +++ b/src/async_impl/mods/api.rs @@ -30,7 +30,7 @@ where request.error.map(|error| ("error", error)), request.foo.map(|foo| ("foo", foo)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("api.test"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/auth.rs b/src/async_impl/mods/auth.rs index b66ed0bf..47ff772b 100644 --- a/src/async_impl/mods/auth.rs +++ b/src/async_impl/mods/auth.rs @@ -33,7 +33,7 @@ where .test .map(|test| ("test", if test { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("auth.revoke"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/bots.rs b/src/async_impl/mods/bots.rs index 7971752e..5403f5d6 100644 --- a/src/async_impl/mods/bots.rs +++ b/src/async_impl/mods/bots.rs @@ -28,7 +28,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), request.bot.map(|bot| ("bot", bot))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("bots.info"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/channels.rs b/src/async_impl/mods/channels.rs index cd11646b..5c0dc3bd 100644 --- a/src/async_impl/mods/channels.rs +++ b/src/async_impl/mods/channels.rs @@ -30,7 +30,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.archive"); client .send(&url, ¶ms[..]) @@ -62,7 +62,7 @@ where .validate .map(|validate| ("validate", if validate { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.create"); client .send(&url, ¶ms[..]) @@ -103,7 +103,7 @@ where .unreads .map(|unreads| ("unreads", if unreads { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.history"); client .send(&url, ¶ms[..]) @@ -129,7 +129,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.info"); client .send(&url, ¶ms[..]) @@ -159,7 +159,7 @@ where Some(("channel", request.channel)), Some(("user", request.user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.invite"); client .send(&url, ¶ms[..]) @@ -191,7 +191,7 @@ where .validate .map(|validate| ("validate", if validate { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.join"); client .send(&url, ¶ms[..]) @@ -221,7 +221,7 @@ where Some(("channel", request.channel)), Some(("user", request.user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.kick"); client .send(&url, ¶ms[..]) @@ -247,7 +247,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.leave"); client .send(&url, ¶ms[..]) @@ -281,7 +281,7 @@ where .exclude_members .map(|exclude_members| ("exclude_members", if exclude_members { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.list"); client .send(&url, ¶ms[..]) @@ -312,7 +312,7 @@ where Some(("channel", request.channel)), Some(("ts", &ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.mark"); client .send(&url, ¶ms[..]) @@ -345,7 +345,7 @@ where .validate .map(|validate| ("validate", if validate { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.rename"); client .send(&url, ¶ms[..]) @@ -376,7 +376,7 @@ where Some(("channel", request.channel)), Some(("thread_ts", &thread_ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.replies"); client .send(&url, ¶ms[..]) @@ -406,7 +406,7 @@ where Some(("channel", request.channel)), Some(("purpose", request.purpose)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.setPurpose"); client .send(&url, ¶ms[..]) @@ -436,7 +436,7 @@ where Some(("channel", request.channel)), Some(("topic", request.topic)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.setTopic"); client .send(&url, ¶ms[..]) @@ -462,7 +462,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.unarchive"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/chat.rs b/src/async_impl/mods/chat.rs index a7e76228..00f8490d 100644 --- a/src/async_impl/mods/chat.rs +++ b/src/async_impl/mods/chat.rs @@ -38,7 +38,7 @@ where .as_user .map(|as_user| ("as_user", if as_user { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("chat.delete"); client .send(&url, ¶ms[..]) @@ -68,7 +68,7 @@ where Some(("channel", request.channel)), Some(("text", request.text)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("chat.meMessage"); client .send(&url, ¶ms[..]) @@ -126,7 +126,7 @@ where .reply_broadcast .map(|reply_broadcast| ("reply_broadcast", if reply_broadcast { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("chat.postMessage"); client .send(&url, ¶ms[..]) @@ -163,7 +163,7 @@ where ) }), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("chat.unfurl"); client .send(&url, ¶ms[..]) @@ -205,7 +205,7 @@ where .as_user .map(|as_user| ("as_user", if as_user { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("chat.update"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/dnd.rs b/src/async_impl/mods/dnd.rs index bd502e3c..0f79aeb6 100644 --- a/src/async_impl/mods/dnd.rs +++ b/src/async_impl/mods/dnd.rs @@ -78,7 +78,7 @@ where Some(("token", token)), request.user.map(|user| ("user", user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("dnd.info"); client .send(&url, ¶ms[..]) @@ -108,7 +108,7 @@ where Some(("token", token)), Some(("num_minutes", &num_minutes[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("dnd.setSnooze"); client .send(&url, ¶ms[..]) @@ -137,7 +137,7 @@ where Some(("token", token)), request.users.map(|users| ("users", users)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("dnd.teamInfo"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/files.rs b/src/async_impl/mods/files.rs index d072f31f..457c9306 100644 --- a/src/async_impl/mods/files.rs +++ b/src/async_impl/mods/files.rs @@ -30,7 +30,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("file", request.file))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.delete"); client .send(&url, ¶ms[..]) @@ -63,7 +63,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.info"); client .send(&url, ¶ms[..]) @@ -102,7 +102,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.list"); client .send(&url, ¶ms[..]) @@ -128,7 +128,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("file", request.file))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.revokePublicURL"); client .send(&url, ¶ms[..]) @@ -154,7 +154,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("file", request.file))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.sharedPublicURL"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/files_comments.rs b/src/async_impl/mods/files_comments.rs index cdf06298..7c82db21 100644 --- a/src/async_impl/mods/files_comments.rs +++ b/src/async_impl/mods/files_comments.rs @@ -32,7 +32,7 @@ where Some(("file", request.file)), Some(("comment", request.comment)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.comments.add"); client .send(&url, ¶ms[..]) @@ -62,7 +62,7 @@ where Some(("file", request.file)), Some(("id", request.id)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.comments.delete"); client .send(&url, ¶ms[..]) @@ -93,7 +93,7 @@ where Some(("id", request.id)), Some(("comment", request.comment)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.comments.edit"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/groups.rs b/src/async_impl/mods/groups.rs index d92af205..3b5efc2e 100644 --- a/src/async_impl/mods/groups.rs +++ b/src/async_impl/mods/groups.rs @@ -30,7 +30,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.archive"); client .send(&url, ¶ms[..]) @@ -56,7 +56,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.close"); client .send(&url, ¶ms[..]) @@ -88,7 +88,7 @@ where .validate .map(|validate| ("validate", if validate { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.create"); client .send(&url, ¶ms[..]) @@ -114,7 +114,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.createChild"); client .send(&url, ¶ms[..]) @@ -155,7 +155,7 @@ where .unreads .map(|unreads| ("unreads", if unreads { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.history"); client .send(&url, ¶ms[..]) @@ -181,7 +181,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.info"); client .send(&url, ¶ms[..]) @@ -211,7 +211,7 @@ where Some(("channel", request.channel)), Some(("user", request.user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.invite"); client .send(&url, ¶ms[..]) @@ -241,7 +241,7 @@ where Some(("channel", request.channel)), Some(("user", request.user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.kick"); client .send(&url, ¶ms[..]) @@ -267,7 +267,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.leave"); client .send(&url, ¶ms[..]) @@ -298,7 +298,7 @@ where .exclude_archived .map(|exclude_archived| ("exclude_archived", if exclude_archived { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.list"); client .send(&url, ¶ms[..]) @@ -329,7 +329,7 @@ where Some(("channel", request.channel)), Some(("ts", &ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.mark"); client .send(&url, ¶ms[..]) @@ -355,7 +355,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.open"); client .send(&url, ¶ms[..]) @@ -388,7 +388,7 @@ where .validate .map(|validate| ("validate", if validate { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.rename"); client .send(&url, ¶ms[..]) @@ -419,7 +419,7 @@ where Some(("channel", request.channel)), Some(("thread_ts", &thread_ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.replies"); client .send(&url, ¶ms[..]) @@ -449,7 +449,7 @@ where Some(("channel", request.channel)), Some(("purpose", request.purpose)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.setPurpose"); client .send(&url, ¶ms[..]) @@ -479,7 +479,7 @@ where Some(("channel", request.channel)), Some(("topic", request.topic)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.setTopic"); client .send(&url, ¶ms[..]) @@ -505,7 +505,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.unarchive"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/im.rs b/src/async_impl/mods/im.rs index 9f5d792a..6e7c8ddb 100644 --- a/src/async_impl/mods/im.rs +++ b/src/async_impl/mods/im.rs @@ -30,7 +30,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.close"); client .send(&url, ¶ms[..]) @@ -71,7 +71,7 @@ where .unreads .map(|unreads| ("unreads", if unreads { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.history"); client .send(&url, ¶ms[..]) @@ -102,7 +102,7 @@ where request.cursor.map(|cursor| ("cursor", cursor)), limit.as_ref().map(|limit| ("limit", &limit[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.list"); client .send(&url, ¶ms[..]) @@ -133,7 +133,7 @@ where Some(("channel", request.channel)), Some(("ts", &ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.mark"); client .send(&url, ¶ms[..]) @@ -165,7 +165,7 @@ where .return_im .map(|return_im| ("return_im", if return_im { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.open"); client .send(&url, ¶ms[..]) @@ -196,7 +196,7 @@ where Some(("channel", request.channel)), Some(("thread_ts", &thread_ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.replies"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/mod.rs b/src/async_impl/mods/mod.rs index 24fb40f2..cc482a9c 100644 --- a/src/async_impl/mods/mod.rs +++ b/src/async_impl/mods/mod.rs @@ -5,8 +5,8 @@ pub mod channels; pub mod chat; pub mod dnd; pub mod emoji; -pub mod files_comments; pub mod files; +pub mod files_comments; pub mod groups; pub mod im; pub mod mpim; @@ -22,4 +22,4 @@ pub mod team_profile; pub mod usergroups; pub mod usergroups_users; pub mod users; -pub mod users_profile; \ No newline at end of file +pub mod users_profile; diff --git a/src/async_impl/mods/mpim.rs b/src/async_impl/mods/mpim.rs index 53dfdb8d..05d84fa4 100644 --- a/src/async_impl/mods/mpim.rs +++ b/src/async_impl/mods/mpim.rs @@ -30,7 +30,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("mpim.close"); client .send(&url, ¶ms[..]) @@ -71,7 +71,7 @@ where .unreads .map(|unreads| ("unreads", if unreads { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("mpim.history"); client .send(&url, ¶ms[..]) @@ -123,7 +123,7 @@ where Some(("channel", request.channel)), Some(("ts", &ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("mpim.mark"); client .send(&url, ¶ms[..]) @@ -149,7 +149,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("users", request.users))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("mpim.open"); client .send(&url, ¶ms[..]) @@ -180,7 +180,7 @@ where Some(("channel", request.channel)), Some(("thread_ts", &thread_ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("mpim.replies"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/oauth.rs b/src/async_impl/mods/oauth.rs index d0780b30..71a211f7 100644 --- a/src/async_impl/mods/oauth.rs +++ b/src/async_impl/mods/oauth.rs @@ -34,7 +34,7 @@ where .redirect_uri .map(|redirect_uri| ("redirect_uri", redirect_uri)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("oauth.access"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/pins.rs b/src/async_impl/mods/pins.rs index eb3c3731..096f16fb 100644 --- a/src/async_impl/mods/pins.rs +++ b/src/async_impl/mods/pins.rs @@ -39,7 +39,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("pins.add"); client .send(&url, ¶ms[..]) @@ -65,7 +65,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("pins.list"); client .send(&url, ¶ms[..]) @@ -102,7 +102,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("pins.remove"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/reactions.rs b/src/async_impl/mods/reactions.rs index 53defe07..e1a42eee 100644 --- a/src/async_impl/mods/reactions.rs +++ b/src/async_impl/mods/reactions.rs @@ -40,7 +40,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reactions.add"); client .send(&url, ¶ms[..]) @@ -80,7 +80,7 @@ where .full .map(|full| ("full", if full { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reactions.get"); client .send(&url, ¶ms[..]) @@ -116,7 +116,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reactions.list"); client .send(&url, ¶ms[..]) @@ -154,7 +154,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reactions.remove"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/reminders.rs b/src/async_impl/mods/reminders.rs index df984830..492c14d4 100644 --- a/src/async_impl/mods/reminders.rs +++ b/src/async_impl/mods/reminders.rs @@ -34,7 +34,7 @@ where Some(("time", &time[..])), request.user.map(|user| ("user", user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reminders.add"); client .send(&url, ¶ms[..]) @@ -60,7 +60,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("reminder", request.reminder))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reminders.complete"); client .send(&url, ¶ms[..]) @@ -86,7 +86,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("reminder", request.reminder))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reminders.delete"); client .send(&url, ¶ms[..]) @@ -112,7 +112,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("reminder", request.reminder))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reminders.info"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/rtm.rs b/src/async_impl/mods/rtm.rs index 85821a5c..d5ce9426 100644 --- a/src/async_impl/mods/rtm.rs +++ b/src/async_impl/mods/rtm.rs @@ -69,7 +69,7 @@ where .include_locale .map(|include_locale| ("include_locale", if include_locale { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("rtm.start"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/search.rs b/src/async_impl/mods/search.rs index ca416bc8..40e2464a 100644 --- a/src/async_impl/mods/search.rs +++ b/src/async_impl/mods/search.rs @@ -42,7 +42,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("search.all"); client .send(&url, ¶ms[..]) @@ -80,7 +80,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("search.files"); client .send(&url, ¶ms[..]) @@ -118,7 +118,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("search.messages"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/stars.rs b/src/async_impl/mods/stars.rs index babeac23..df5d84cc 100644 --- a/src/async_impl/mods/stars.rs +++ b/src/async_impl/mods/stars.rs @@ -39,7 +39,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("stars.add"); client .send(&url, ¶ms[..]) @@ -71,7 +71,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("stars.list"); client .send(&url, ¶ms[..]) @@ -108,7 +108,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("stars.remove"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/team.rs b/src/async_impl/mods/team.rs index 2e8c2740..0e120743 100644 --- a/src/async_impl/mods/team.rs +++ b/src/async_impl/mods/team.rs @@ -36,7 +36,7 @@ where page.as_ref().map(|page| ("page", &page[..])), before.as_ref().map(|before| ("before", &before[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("team.accessLogs"); client .send(&url, ¶ms[..]) @@ -65,7 +65,7 @@ where Some(("token", token)), request.user.map(|user| ("user", user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("team.billableInfo"); client .send(&url, ¶ms[..]) @@ -126,7 +126,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("team.integrationLogs"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/team_profile.rs b/src/async_impl/mods/team_profile.rs index bb0ed490..53e7f78a 100644 --- a/src/async_impl/mods/team_profile.rs +++ b/src/async_impl/mods/team_profile.rs @@ -33,7 +33,7 @@ where .visibility .map(|visibility| ("visibility", visibility)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("team.profile.get"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/usergroups.rs b/src/async_impl/mods/usergroups.rs index 35b5eb87..ba36b7ed 100644 --- a/src/async_impl/mods/usergroups.rs +++ b/src/async_impl/mods/usergroups.rs @@ -41,7 +41,7 @@ where .include_count .map(|include_count| ("include_count", if include_count { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.create"); client .send(&url, ¶ms[..]) @@ -73,7 +73,7 @@ where .include_count .map(|include_count| ("include_count", if include_count { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.disable"); client .send(&url, ¶ms[..]) @@ -105,7 +105,7 @@ where .include_count .map(|include_count| ("include_count", if include_count { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.enable"); client .send(&url, ¶ms[..]) @@ -142,7 +142,7 @@ where .include_users .map(|include_users| ("include_users", if include_users { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.list"); client .send(&url, ¶ms[..]) @@ -180,7 +180,7 @@ where .include_count .map(|include_count| ("include_count", if include_count { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.update"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/usergroups_users.rs b/src/async_impl/mods/usergroups_users.rs index 6dbca9c0..4074498e 100644 --- a/src/async_impl/mods/usergroups_users.rs +++ b/src/async_impl/mods/usergroups_users.rs @@ -34,7 +34,7 @@ where .include_disabled .map(|include_disabled| ("include_disabled", if include_disabled { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.users.list"); client .send(&url, ¶ms[..]) @@ -67,7 +67,7 @@ where .include_count .map(|include_count| ("include_count", if include_count { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.users.update"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/users.rs b/src/async_impl/mods/users.rs index ce2000c5..88293b1b 100644 --- a/src/async_impl/mods/users.rs +++ b/src/async_impl/mods/users.rs @@ -54,7 +54,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("user", request.user))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.getPresence"); client .send(&url, ¶ms[..]) @@ -104,7 +104,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("user", request.user))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.info"); client .send(&url, ¶ms[..]) @@ -135,7 +135,7 @@ where .presence .map(|presence| ("presence", if presence { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.list"); client .send(&url, ¶ms[..]) @@ -185,7 +185,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("presence", request.presence))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.setPresence"); client .send(&url, ¶ms[..]) diff --git a/src/async_impl/mods/users_profile.rs b/src/async_impl/mods/users_profile.rs index 9a9b2567..5ce27a9b 100644 --- a/src/async_impl/mods/users_profile.rs +++ b/src/async_impl/mods/users_profile.rs @@ -34,7 +34,7 @@ where .include_labels .map(|include_labels| ("include_labels", if include_labels { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.profile.get"); client .send(&url, ¶ms[..]) @@ -66,7 +66,7 @@ where request.name.map(|name| ("name", name)), request.value.map(|value| ("value", value)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.profile.set"); client .send(&url, ¶ms[..]) diff --git a/src/lib.rs b/src/lib.rs index a222a3e2..4d74fcd5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -90,7 +90,6 @@ where #[cfg(test)] mod tests { use super::UserProfile; - use serde_json; #[test] fn test_user_profile_fields_empty_array_deserialize() { diff --git a/src/mod_types/api_types.rs b/src/mod_types/api_types.rs index f0366b1a..4eb3d0ec 100644 --- a/src/mod_types/api_types.rs +++ b/src/mod_types/api_types.rs @@ -34,12 +34,12 @@ pub struct TestResponse { ok: bool, } -impl Into>> for TestResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: TestResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/auth_types.rs b/src/mod_types/auth_types.rs index e475315c..728e7e40 100644 --- a/src/mod_types/auth_types.rs +++ b/src/mod_types/auth_types.rs @@ -32,12 +32,12 @@ pub struct RevokeResponse { pub revoked: Option, } -impl Into>> for RevokeResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: RevokeResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -136,12 +136,12 @@ pub struct TestResponse { pub user_id: Option, } -impl Into>> for TestResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: TestResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/bots_types.rs b/src/mod_types/bots_types.rs index 5532f442..ca550ec6 100644 --- a/src/mod_types/bots_types.rs +++ b/src/mod_types/bots_types.rs @@ -48,12 +48,12 @@ pub struct InfoResponseBotIcons { pub image_72: Option, } -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: InfoResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/channels_types.rs b/src/mod_types/channels_types.rs index 3ca88dc3..139c8db1 100644 --- a/src/mod_types/channels_types.rs +++ b/src/mod_types/channels_types.rs @@ -33,12 +33,12 @@ pub struct ArchiveResponse { ok: bool, } -impl Into>> for ArchiveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ArchiveResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -165,12 +165,12 @@ pub struct CreateResponse { ok: bool, } -impl Into>> for CreateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: CreateResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -323,12 +323,12 @@ pub struct HistoryResponse { ok: bool, } -impl Into>> for HistoryResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: HistoryResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -441,12 +441,12 @@ pub struct InfoResponse { ok: bool, } -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: InfoResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -553,12 +553,12 @@ pub struct InviteResponse { ok: bool, } -impl Into>> for InviteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: InviteResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -701,12 +701,12 @@ pub struct JoinResponse { ok: bool, } -impl Into>> for JoinResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: JoinResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -856,12 +856,12 @@ pub struct KickResponse { ok: bool, } -impl Into>> for KickResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: KickResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -993,12 +993,12 @@ pub struct LeaveResponse { ok: bool, } -impl Into>> for LeaveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: LeaveResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1121,12 +1121,12 @@ pub struct ListResponse { ok: bool, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1228,12 +1228,12 @@ pub struct MarkResponse { ok: bool, } -impl Into>> for MarkResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: MarkResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1358,12 +1358,12 @@ pub struct RenameResponseChannel { pub name: Option, } -impl Into>> for RenameResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: RenameResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1511,12 +1511,12 @@ pub struct RepliesResponse { pub thread_info: Option, } -impl Into>> for RepliesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: RepliesResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1627,12 +1627,12 @@ pub struct SetPurposeResponse { pub purpose: Option, } -impl Into>> for SetPurposeResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: SetPurposeResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1755,12 +1755,12 @@ pub struct SetTopicResponse { pub topic: Option, } -impl Into>> for SetTopicResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: SetTopicResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1880,12 +1880,12 @@ pub struct UnarchiveResponse { ok: bool, } -impl Into>> for UnarchiveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: UnarchiveResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/chat_types.rs b/src/mod_types/chat_types.rs index 3fa4a705..a850de62 100644 --- a/src/mod_types/chat_types.rs +++ b/src/mod_types/chat_types.rs @@ -39,12 +39,12 @@ pub struct DeleteResponse { pub ts: Option, } -impl Into>> for DeleteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: DeleteResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -164,12 +164,12 @@ pub struct MeMessageResponse { pub ts: Option, } -impl Into>> for MeMessageResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: MeMessageResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -320,12 +320,12 @@ pub struct PostMessageResponse { pub ts: Option, } -impl Into>> for PostMessageResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: PostMessageResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -459,12 +459,12 @@ pub struct UnfurlResponse { ok: bool, } -impl Into>> for UnfurlResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: UnfurlResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -583,12 +583,12 @@ pub struct UpdateResponse { pub ts: Option, } -impl Into>> for UpdateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: UpdateResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/dnd_types.rs b/src/mod_types/dnd_types.rs index d608ae4d..2c28bffa 100644 --- a/src/mod_types/dnd_types.rs +++ b/src/mod_types/dnd_types.rs @@ -27,12 +27,12 @@ pub struct EndDndResponse { ok: bool, } -impl Into>> for EndDndResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: EndDndResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -138,12 +138,12 @@ pub struct EndSnoozeResponse { pub snooze_enabled: Option, } -impl Into>> for EndSnoozeResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: EndSnoozeResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -261,12 +261,12 @@ pub struct InfoResponse { pub snooze_remaining: Option, } -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: InfoResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -373,12 +373,12 @@ pub struct SetSnoozeResponse { pub snooze_remaining: Option, } -impl Into>> for SetSnoozeResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: SetSnoozeResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -491,12 +491,12 @@ pub struct TeamInfoResponse { pub users: Option>, } -impl Into>> for TeamInfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: TeamInfoResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/emoji_types.rs b/src/mod_types/emoji_types.rs index 81f4db1e..538e28a4 100644 --- a/src/mod_types/emoji_types.rs +++ b/src/mod_types/emoji_types.rs @@ -26,12 +26,12 @@ pub struct ListResponse { ok: bool, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/files_comments_types.rs b/src/mod_types/files_comments_types.rs index 3fa85a3a..525253d9 100644 --- a/src/mod_types/files_comments_types.rs +++ b/src/mod_types/files_comments_types.rs @@ -34,12 +34,12 @@ pub struct AddResponse { ok: bool, } -impl Into>> for AddResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: AddResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -153,12 +153,12 @@ pub struct DeleteResponse { ok: bool, } -impl Into>> for DeleteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: DeleteResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -275,12 +275,12 @@ pub struct EditResponse { ok: bool, } -impl Into>> for EditResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: EditResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/files_types.rs b/src/mod_types/files_types.rs index d9b1b2a2..3f56b238 100644 --- a/src/mod_types/files_types.rs +++ b/src/mod_types/files_types.rs @@ -33,12 +33,12 @@ pub struct DeleteResponse { ok: bool, } -impl Into>> for DeleteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: DeleteResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -157,12 +157,12 @@ pub struct InfoResponse { pub paging: Option, } -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: InfoResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -296,12 +296,12 @@ pub struct ListResponse { pub paging: Option, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -414,14 +414,14 @@ pub struct RevokePublicURLResponse { ok: bool, } -impl Into>> - for RevokePublicURLResponse +impl From + for Result> { - fn into(self) -> Result> { - if self.ok { - Ok(self) + fn from(val: RevokePublicURLResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -534,14 +534,14 @@ pub struct SharedPublicURLResponse { ok: bool, } -impl Into>> - for SharedPublicURLResponse +impl From + for Result> { - fn into(self) -> Result> { - if self.ok { - Ok(self) + fn from(val: SharedPublicURLResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/groups_types.rs b/src/mod_types/groups_types.rs index 2ee4de1e..c2966c09 100644 --- a/src/mod_types/groups_types.rs +++ b/src/mod_types/groups_types.rs @@ -33,12 +33,12 @@ pub struct ArchiveResponse { ok: bool, } -impl Into>> for ArchiveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ArchiveResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -162,12 +162,12 @@ pub struct CloseResponse { ok: bool, } -impl Into>> for CloseResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: CloseResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -274,12 +274,12 @@ pub struct CreateResponse { ok: bool, } -impl Into>> for CreateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: CreateResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -420,12 +420,12 @@ pub struct CreateChildResponse { ok: bool, } -impl Into>> for CreateChildResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: CreateChildResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -558,12 +558,12 @@ pub struct HistoryResponse { ok: bool, } -impl Into>> for HistoryResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: HistoryResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -676,12 +676,12 @@ pub struct InfoResponse { ok: bool, } -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: InfoResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -788,12 +788,12 @@ pub struct InviteResponse { ok: bool, } -impl Into>> for InviteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: InviteResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -927,12 +927,12 @@ pub struct KickResponse { ok: bool, } -impl Into>> for KickResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: KickResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1060,12 +1060,12 @@ pub struct LeaveResponse { ok: bool, } -impl Into>> for LeaveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: LeaveResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1182,12 +1182,12 @@ pub struct ListResponse { ok: bool, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1289,12 +1289,12 @@ pub struct MarkResponse { ok: bool, } -impl Into>> for MarkResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: MarkResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1402,12 +1402,12 @@ pub struct OpenResponse { ok: bool, } -impl Into>> for OpenResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: OpenResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1524,12 +1524,12 @@ pub struct RenameResponseChannel { pub name: Option, } -impl Into>> for RenameResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: RenameResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1669,12 +1669,12 @@ pub struct RepliesResponse { pub thread_info: Option, } -impl Into>> for RepliesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: RepliesResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1789,12 +1789,12 @@ pub struct SetPurposeResponse { pub purpose: Option, } -impl Into>> for SetPurposeResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: SetPurposeResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -1913,12 +1913,12 @@ pub struct SetTopicResponse { pub topic: Option, } -impl Into>> for SetTopicResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: SetTopicResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -2034,12 +2034,12 @@ pub struct UnarchiveResponse { ok: bool, } -impl Into>> for UnarchiveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: UnarchiveResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/im_types.rs b/src/mod_types/im_types.rs index 6aec8bf6..6be60975 100644 --- a/src/mod_types/im_types.rs +++ b/src/mod_types/im_types.rs @@ -33,12 +33,12 @@ pub struct CloseResponse { ok: bool, } -impl Into>> for CloseResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: CloseResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -159,12 +159,12 @@ pub struct HistoryResponse { ok: bool, } -impl Into>> for HistoryResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: HistoryResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -279,12 +279,12 @@ pub struct ListResponse { ok: bool, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -386,12 +386,12 @@ pub struct MarkResponse { ok: bool, } -impl Into>> for MarkResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: MarkResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -506,12 +506,12 @@ pub struct OpenResponse { ok: bool, } -impl Into>> for OpenResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: OpenResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -627,12 +627,12 @@ pub struct RepliesResponse { pub thread_info: Option, } -impl Into>> for RepliesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: RepliesResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/mod.rs b/src/mod_types/mod.rs index bf58ead8..e048973e 100644 --- a/src/mod_types/mod.rs +++ b/src/mod_types/mod.rs @@ -17,9 +17,9 @@ pub mod reminders_types; pub mod rtm_types; pub mod search_types; pub mod stars_types; -pub mod team_types; pub mod team_profile_types; +pub mod team_types; pub mod usergroups_types; pub mod usergroups_users_types; +pub mod users_profile_types; pub mod users_types; -pub mod users_profile_types; \ No newline at end of file diff --git a/src/mod_types/mpim_types.rs b/src/mod_types/mpim_types.rs index e85ae0bf..9ca37d3f 100644 --- a/src/mod_types/mpim_types.rs +++ b/src/mod_types/mpim_types.rs @@ -33,12 +33,12 @@ pub struct CloseResponse { ok: bool, } -impl Into>> for CloseResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: CloseResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -155,12 +155,12 @@ pub struct HistoryResponse { ok: bool, } -impl Into>> for HistoryResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: HistoryResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -267,12 +267,12 @@ pub struct ListResponse { ok: bool, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -374,12 +374,12 @@ pub struct MarkResponse { ok: bool, } -impl Into>> for MarkResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: MarkResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -488,12 +488,12 @@ pub struct OpenResponse { ok: bool, } -impl Into>> for OpenResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: OpenResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -609,12 +609,12 @@ pub struct RepliesResponse { pub thread_info: Option, } -impl Into>> for RepliesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: RepliesResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/pins_types.rs b/src/mod_types/pins_types.rs index 52bb0b93..7bdffa9c 100644 --- a/src/mod_types/pins_types.rs +++ b/src/mod_types/pins_types.rs @@ -37,12 +37,12 @@ pub struct AddResponse { ok: bool, } -impl Into>> for AddResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: AddResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -201,14 +201,14 @@ impl<'de> ::serde::Deserialize<'de> for ListResponseItem { match ty { "message" => ::serde_json::from_value::(value.clone()) .map(ListResponseItem::Message) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "file" => ::serde_json::from_value::(value.clone()) .map(ListResponseItem::File) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "file_comment" => { ::serde_json::from_value::(value.clone()) .map(ListResponseItem::FileComment) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } _ => Err(D::Error::unknown_variant(ty, VARIANTS)), } @@ -253,12 +253,12 @@ pub struct ListResponseItemMessage { pub ty: String, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -368,12 +368,12 @@ pub struct RemoveResponse { ok: bool, } -impl Into>> for RemoveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: RemoveResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/reactions_types.rs b/src/mod_types/reactions_types.rs index 23d1bcf1..7e66c0ad 100644 --- a/src/mod_types/reactions_types.rs +++ b/src/mod_types/reactions_types.rs @@ -39,12 +39,12 @@ pub struct AddResponse { ok: bool, } -impl Into>> for AddResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: AddResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -203,14 +203,14 @@ impl<'de> ::serde::Deserialize<'de> for GetResponse { match ty { "message" => ::serde_json::from_value::(value.clone()) .map(GetResponse::Message) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "file" => ::serde_json::from_value::(value.clone()) .map(GetResponse::File) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "file_comment" => { ::serde_json::from_value::(value.clone()) .map(GetResponse::FileComment) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } _ => Err(D::Error::unknown_variant(ty, VARIANTS)), } @@ -258,9 +258,9 @@ pub struct GetResponseMessage { pub ty: String, } -impl Into>> for GetResponse { - fn into(self) -> Result> { - match self { +impl From for Result> { + fn from(val: GetResponse) -> Self { + match val { GetResponse::Message(inner) => { let x: Result> = inner.into(); x.map(GetResponse::Message) @@ -277,30 +277,30 @@ impl Into>> for GetResponse { } } -impl Into>> for GetResponseMessage { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: GetResponseMessage) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } -impl Into>> for GetResponseFile { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: GetResponseFile) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } -impl Into>> for GetResponseFileComment { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: GetResponseFileComment) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -450,14 +450,14 @@ impl<'de> ::serde::Deserialize<'de> for ListResponseItem { match ty { "message" => ::serde_json::from_value::(value.clone()) .map(ListResponseItem::Message) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "file" => ::serde_json::from_value::(value.clone()) .map(ListResponseItem::File) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "file_comment" => { ::serde_json::from_value::(value.clone()) .map(ListResponseItem::FileComment) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } _ => Err(D::Error::unknown_variant(ty, VARIANTS)), } @@ -496,12 +496,12 @@ pub struct ListResponseItemMessage { pub ty: String, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -613,12 +613,12 @@ pub struct RemoveResponse { ok: bool, } -impl Into>> for RemoveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: RemoveResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/reminders_types.rs b/src/mod_types/reminders_types.rs index dc22fccf..1729f726 100644 --- a/src/mod_types/reminders_types.rs +++ b/src/mod_types/reminders_types.rs @@ -36,12 +36,12 @@ pub struct AddResponse { pub reminder: Option, } -impl Into>> for AddResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: AddResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -169,12 +169,12 @@ pub struct CompleteResponse { ok: bool, } -impl Into>> for CompleteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: CompleteResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -290,12 +290,12 @@ pub struct DeleteResponse { ok: bool, } -impl Into>> for DeleteResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: DeleteResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -404,12 +404,12 @@ pub struct InfoResponse { pub reminder: Option, } -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: InfoResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -512,12 +512,12 @@ pub struct ListResponse { pub reminders: Option>, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/rtm_types.rs b/src/mod_types/rtm_types.rs index f1e8ce0d..27c89b13 100644 --- a/src/mod_types/rtm_types.rs +++ b/src/mod_types/rtm_types.rs @@ -44,12 +44,12 @@ pub struct ConnectResponseTeam { pub name: Option, } -impl Into>> for ConnectResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ConnectResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -167,12 +167,12 @@ pub struct StartResponse { pub users: Option>, } -impl Into>> for StartResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: StartResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/search_types.rs b/src/mod_types/search_types.rs index 383379a5..1b5df69b 100644 --- a/src/mod_types/search_types.rs +++ b/src/mod_types/search_types.rs @@ -58,12 +58,12 @@ pub struct AllResponseMessages { pub paging: crate::Paging, } -impl Into>> for AllResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: AllResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -186,12 +186,12 @@ pub struct FilesResponseFiles { pub total: Option, } -impl Into>> for FilesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: FilesResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -314,12 +314,12 @@ pub struct MessagesResponseMessages { pub total: Option, } -impl Into>> for MessagesResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: MessagesResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/stars_types.rs b/src/mod_types/stars_types.rs index 35eca4d4..b92aa3c3 100644 --- a/src/mod_types/stars_types.rs +++ b/src/mod_types/stars_types.rs @@ -37,12 +37,12 @@ pub struct AddResponse { ok: bool, } -impl Into>> for AddResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: AddResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -199,24 +199,24 @@ impl<'de> ::serde::Deserialize<'de> for ListResponseItem { match ty { "message" => ::serde_json::from_value::(value.clone()) .map(ListResponseItem::Message) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "file" => ::serde_json::from_value::(value.clone()) .map(ListResponseItem::File) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "file_comment" => { ::serde_json::from_value::(value.clone()) .map(ListResponseItem::FileComment) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "channel" => ::serde_json::from_value::(value.clone()) .map(ListResponseItem::Channel) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "im" => ::serde_json::from_value::(value.clone()) .map(ListResponseItem::Im) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "group" => ::serde_json::from_value::(value.clone()) .map(ListResponseItem::Group) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), _ => Err(D::Error::unknown_variant(ty, VARIANTS)), } } else { @@ -275,12 +275,12 @@ pub struct ListResponseItemMessage { pub ty: String, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -398,12 +398,12 @@ pub struct RemoveResponse { ok: bool, } -impl Into>> for RemoveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: RemoveResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/team_profile_types.rs b/src/mod_types/team_profile_types.rs index fe32733b..47dc60ea 100644 --- a/src/mod_types/team_profile_types.rs +++ b/src/mod_types/team_profile_types.rs @@ -50,12 +50,12 @@ pub struct GetResponseProfileField { pub ty: Option, } -impl Into>> for GetResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: GetResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/team_types.rs b/src/mod_types/team_types.rs index 6a59dd36..92adeb6b 100644 --- a/src/mod_types/team_types.rs +++ b/src/mod_types/team_types.rs @@ -51,12 +51,12 @@ pub struct AccessLogsResponseLogin { pub username: Option, } -impl Into>> for AccessLogsResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: AccessLogsResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -169,12 +169,12 @@ pub struct BillableInfoResponse { ok: bool, } -impl Into>> for BillableInfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: BillableInfoResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -277,12 +277,12 @@ pub struct InfoResponse { pub team: Option, } -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: InfoResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -409,14 +409,14 @@ pub struct IntegrationLogsResponseLog { pub user_name: Option, } -impl Into>> - for IntegrationLogsResponse +impl From + for Result> { - fn into(self) -> Result> { - if self.ok { - Ok(self) + fn from(val: IntegrationLogsResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/usergroups_types.rs b/src/mod_types/usergroups_types.rs index c56d3f30..67a10b53 100644 --- a/src/mod_types/usergroups_types.rs +++ b/src/mod_types/usergroups_types.rs @@ -42,12 +42,12 @@ pub struct CreateResponse { pub usergroup: Option, } -impl Into>> for CreateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: CreateResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -158,12 +158,12 @@ pub struct DisableResponse { pub usergroup: Option, } -impl Into>> for DisableResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: DisableResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -274,12 +274,12 @@ pub struct EnableResponse { pub usergroup: Option, } -impl Into>> for EnableResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: EnableResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -392,12 +392,12 @@ pub struct ListResponse { pub usergroups: Option>, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -516,12 +516,12 @@ pub struct UpdateResponse { pub usergroup: Option, } -impl Into>> for UpdateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: UpdateResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/usergroups_users_types.rs b/src/mod_types/usergroups_users_types.rs index 97425c07..804246df 100644 --- a/src/mod_types/usergroups_users_types.rs +++ b/src/mod_types/usergroups_users_types.rs @@ -34,12 +34,12 @@ pub struct ListResponse { pub users: Option>, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -152,12 +152,12 @@ pub struct UpdateResponse { pub usergroup: Option, } -impl Into>> for UpdateResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: UpdateResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/users_profile_types.rs b/src/mod_types/users_profile_types.rs index 94fcdfe1..d5ca67fa 100644 --- a/src/mod_types/users_profile_types.rs +++ b/src/mod_types/users_profile_types.rs @@ -34,12 +34,12 @@ pub struct GetResponse { pub profile: Option, } -impl Into>> for GetResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: GetResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -154,12 +154,12 @@ pub struct SetResponse { pub profile: Option, } -impl Into>> for SetResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: SetResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/mod_types/users_types.rs b/src/mod_types/users_types.rs index ef8d5f57..45de6a3e 100644 --- a/src/mod_types/users_types.rs +++ b/src/mod_types/users_types.rs @@ -27,12 +27,12 @@ pub struct DeletePhotoResponse { ok: bool, } -impl Into>> for DeletePhotoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: DeletePhotoResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -137,12 +137,12 @@ pub struct GetPresenceResponse { pub presence: Option, } -impl Into>> for GetPresenceResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: GetPresenceResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -238,12 +238,12 @@ pub struct IdentityResponse { pub user: Option, } -impl Into>> for IdentityResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: IdentityResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -348,12 +348,12 @@ pub struct InfoResponse { pub user: Option, } -impl Into>> for InfoResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: InfoResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -462,12 +462,12 @@ pub struct ListResponse { ok: bool, } -impl Into>> for ListResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: ListResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -561,12 +561,12 @@ pub struct SetActiveResponse { ok: bool, } -impl Into>> for SetActiveResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: SetActiveResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } @@ -666,12 +666,12 @@ pub struct SetPresenceResponse { ok: bool, } -impl Into>> for SetPresenceResponse { - fn into(self) -> Result> { - if self.ok { - Ok(self) +impl From for Result> { + fn from(val: SetPresenceResponse) -> Self { + if val.ok { + Ok(val) } else { - Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) + Err(val.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } diff --git a/src/sync/mods/api.rs b/src/sync/mods/api.rs index 80967c99..aa600b0d 100644 --- a/src/sync/mods/api.rs +++ b/src/sync/mods/api.rs @@ -27,7 +27,7 @@ where request.error.map(|error| ("error", error)), request.foo.map(|foo| ("foo", foo)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("api.test"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/auth.rs b/src/sync/mods/auth.rs index 8eed7293..1b33a539 100644 --- a/src/sync/mods/auth.rs +++ b/src/sync/mods/auth.rs @@ -33,7 +33,7 @@ where .test .map(|test| ("test", if test { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("auth.revoke"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/bots.rs b/src/sync/mods/bots.rs index 19f89030..a79a7ed2 100644 --- a/src/sync/mods/bots.rs +++ b/src/sync/mods/bots.rs @@ -28,7 +28,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), request.bot.map(|bot| ("bot", bot))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("bots.info"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/channels.rs b/src/sync/mods/channels.rs index b096aa24..06afdef2 100644 --- a/src/sync/mods/channels.rs +++ b/src/sync/mods/channels.rs @@ -30,7 +30,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.archive"); client .send(&url, ¶ms[..]) @@ -61,7 +61,7 @@ where .validate .map(|validate| ("validate", if validate { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.create"); client .send(&url, ¶ms[..]) @@ -101,7 +101,7 @@ where .unreads .map(|unreads| ("unreads", if unreads { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.history"); client .send(&url, ¶ms[..]) @@ -126,7 +126,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.info"); client .send(&url, ¶ms[..]) @@ -155,7 +155,7 @@ where Some(("channel", request.channel)), Some(("user", request.user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.invite"); client .send(&url, ¶ms[..]) @@ -186,7 +186,7 @@ where .validate .map(|validate| ("validate", if validate { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.join"); client .send(&url, ¶ms[..]) @@ -215,7 +215,7 @@ where Some(("channel", request.channel)), Some(("user", request.user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.kick"); client .send(&url, ¶ms[..]) @@ -240,7 +240,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.leave"); client .send(&url, ¶ms[..]) @@ -273,7 +273,7 @@ where .exclude_members .map(|exclude_members| ("exclude_members", if exclude_members { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.list"); client .send(&url, ¶ms[..]) @@ -303,7 +303,7 @@ where Some(("channel", request.channel)), Some(("ts", &ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.mark"); client .send(&url, ¶ms[..]) @@ -335,7 +335,7 @@ where .validate .map(|validate| ("validate", if validate { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.rename"); client .send(&url, ¶ms[..]) @@ -365,7 +365,7 @@ where Some(("channel", request.channel)), Some(("thread_ts", &thread_ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.replies"); client .send(&url, ¶ms[..]) @@ -394,7 +394,7 @@ where Some(("channel", request.channel)), Some(("purpose", request.purpose)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.setPurpose"); client .send(&url, ¶ms[..]) @@ -423,7 +423,7 @@ where Some(("channel", request.channel)), Some(("topic", request.topic)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.setTopic"); client .send(&url, ¶ms[..]) @@ -448,7 +448,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("channels.unarchive"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/chat.rs b/src/sync/mods/chat.rs index db66ba8c..a833c668 100644 --- a/src/sync/mods/chat.rs +++ b/src/sync/mods/chat.rs @@ -38,7 +38,7 @@ where .as_user .map(|as_user| ("as_user", if as_user { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("chat.delete"); client .send(&url, ¶ms[..]) @@ -67,7 +67,7 @@ where Some(("channel", request.channel)), Some(("text", request.text)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("chat.meMessage"); client .send(&url, ¶ms[..]) @@ -124,7 +124,7 @@ where .reply_broadcast .map(|reply_broadcast| ("reply_broadcast", if reply_broadcast { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("chat.postMessage"); client .send(&url, ¶ms[..]) @@ -160,7 +160,7 @@ where ) }), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("chat.unfurl"); client .send(&url, ¶ms[..]) @@ -201,7 +201,7 @@ where .as_user .map(|as_user| ("as_user", if as_user { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("chat.update"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/dnd.rs b/src/sync/mods/dnd.rs index 71b8cfe9..3ee52898 100644 --- a/src/sync/mods/dnd.rs +++ b/src/sync/mods/dnd.rs @@ -73,7 +73,7 @@ where Some(("token", token)), request.user.map(|user| ("user", user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("dnd.info"); client .send(&url, ¶ms[..]) @@ -102,7 +102,7 @@ where Some(("token", token)), Some(("num_minutes", &num_minutes[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("dnd.setSnooze"); client .send(&url, ¶ms[..]) @@ -130,7 +130,7 @@ where Some(("token", token)), request.users.map(|users| ("users", users)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("dnd.teamInfo"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/files.rs b/src/sync/mods/files.rs index bcb6d274..f2159a04 100644 --- a/src/sync/mods/files.rs +++ b/src/sync/mods/files.rs @@ -30,7 +30,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("file", request.file))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.delete"); client .send(&url, ¶ms[..]) @@ -62,7 +62,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.info"); client .send(&url, ¶ms[..]) @@ -100,7 +100,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.list"); client .send(&url, ¶ms[..]) @@ -125,7 +125,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("file", request.file))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.revokePublicURL"); client .send(&url, ¶ms[..]) @@ -150,7 +150,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("file", request.file))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.sharedPublicURL"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/files_comments.rs b/src/sync/mods/files_comments.rs index 4c8d7f33..cad13a72 100644 --- a/src/sync/mods/files_comments.rs +++ b/src/sync/mods/files_comments.rs @@ -32,7 +32,7 @@ where Some(("file", request.file)), Some(("comment", request.comment)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.comments.add"); client .send(&url, ¶ms[..]) @@ -61,7 +61,7 @@ where Some(("file", request.file)), Some(("id", request.id)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.comments.delete"); client .send(&url, ¶ms[..]) @@ -91,7 +91,7 @@ where Some(("id", request.id)), Some(("comment", request.comment)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("files.comments.edit"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/groups.rs b/src/sync/mods/groups.rs index ca953a29..4704ac8d 100644 --- a/src/sync/mods/groups.rs +++ b/src/sync/mods/groups.rs @@ -30,7 +30,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.archive"); client .send(&url, ¶ms[..]) @@ -55,7 +55,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.close"); client .send(&url, ¶ms[..]) @@ -86,7 +86,7 @@ where .validate .map(|validate| ("validate", if validate { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.create"); client .send(&url, ¶ms[..]) @@ -111,7 +111,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.createChild"); client .send(&url, ¶ms[..]) @@ -151,7 +151,7 @@ where .unreads .map(|unreads| ("unreads", if unreads { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.history"); client .send(&url, ¶ms[..]) @@ -176,7 +176,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.info"); client .send(&url, ¶ms[..]) @@ -205,7 +205,7 @@ where Some(("channel", request.channel)), Some(("user", request.user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.invite"); client .send(&url, ¶ms[..]) @@ -234,7 +234,7 @@ where Some(("channel", request.channel)), Some(("user", request.user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.kick"); client .send(&url, ¶ms[..]) @@ -259,7 +259,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.leave"); client .send(&url, ¶ms[..]) @@ -289,7 +289,7 @@ where .exclude_archived .map(|exclude_archived| ("exclude_archived", if exclude_archived { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.list"); client .send(&url, ¶ms[..]) @@ -319,7 +319,7 @@ where Some(("channel", request.channel)), Some(("ts", &ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.mark"); client .send(&url, ¶ms[..]) @@ -344,7 +344,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.open"); client .send(&url, ¶ms[..]) @@ -376,7 +376,7 @@ where .validate .map(|validate| ("validate", if validate { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.rename"); client .send(&url, ¶ms[..]) @@ -406,7 +406,7 @@ where Some(("channel", request.channel)), Some(("thread_ts", &thread_ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.replies"); client .send(&url, ¶ms[..]) @@ -435,7 +435,7 @@ where Some(("channel", request.channel)), Some(("purpose", request.purpose)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.setPurpose"); client .send(&url, ¶ms[..]) @@ -464,7 +464,7 @@ where Some(("channel", request.channel)), Some(("topic", request.topic)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.setTopic"); client .send(&url, ¶ms[..]) @@ -489,7 +489,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("groups.unarchive"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/im.rs b/src/sync/mods/im.rs index 89cd4245..5811c4ea 100644 --- a/src/sync/mods/im.rs +++ b/src/sync/mods/im.rs @@ -30,7 +30,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.close"); client .send(&url, ¶ms[..]) @@ -70,7 +70,7 @@ where .unreads .map(|unreads| ("unreads", if unreads { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.history"); client .send(&url, ¶ms[..]) @@ -100,7 +100,7 @@ where request.cursor.map(|cursor| ("cursor", cursor)), limit.as_ref().map(|limit| ("limit", &limit[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.list"); client .send(&url, ¶ms[..]) @@ -130,7 +130,7 @@ where Some(("channel", request.channel)), Some(("ts", &ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.mark"); client .send(&url, ¶ms[..]) @@ -161,7 +161,7 @@ where .return_im .map(|return_im| ("return_im", if return_im { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.open"); client .send(&url, ¶ms[..]) @@ -191,7 +191,7 @@ where Some(("channel", request.channel)), Some(("thread_ts", &thread_ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("im.replies"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/mod.rs b/src/sync/mods/mod.rs index 24fb40f2..cc482a9c 100644 --- a/src/sync/mods/mod.rs +++ b/src/sync/mods/mod.rs @@ -5,8 +5,8 @@ pub mod channels; pub mod chat; pub mod dnd; pub mod emoji; -pub mod files_comments; pub mod files; +pub mod files_comments; pub mod groups; pub mod im; pub mod mpim; @@ -22,4 +22,4 @@ pub mod team_profile; pub mod usergroups; pub mod usergroups_users; pub mod users; -pub mod users_profile; \ No newline at end of file +pub mod users_profile; diff --git a/src/sync/mods/mpim.rs b/src/sync/mods/mpim.rs index 221b007e..d6806d95 100644 --- a/src/sync/mods/mpim.rs +++ b/src/sync/mods/mpim.rs @@ -30,7 +30,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("mpim.close"); client .send(&url, ¶ms[..]) @@ -70,7 +70,7 @@ where .unreads .map(|unreads| ("unreads", if unreads { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("mpim.history"); client .send(&url, ¶ms[..]) @@ -120,7 +120,7 @@ where Some(("channel", request.channel)), Some(("ts", &ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("mpim.mark"); client .send(&url, ¶ms[..]) @@ -145,7 +145,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("users", request.users))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("mpim.open"); client .send(&url, ¶ms[..]) @@ -175,7 +175,7 @@ where Some(("channel", request.channel)), Some(("thread_ts", &thread_ts[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("mpim.replies"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/oauth.rs b/src/sync/mods/oauth.rs index 68633524..9a1346ac 100644 --- a/src/sync/mods/oauth.rs +++ b/src/sync/mods/oauth.rs @@ -34,7 +34,7 @@ where .redirect_uri .map(|redirect_uri| ("redirect_uri", redirect_uri)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("oauth.access"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/pins.rs b/src/sync/mods/pins.rs index 4d0c6b70..eb8bfce8 100644 --- a/src/sync/mods/pins.rs +++ b/src/sync/mods/pins.rs @@ -39,7 +39,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("pins.add"); client .send(&url, ¶ms[..]) @@ -64,7 +64,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("channel", request.channel))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("pins.list"); client .send(&url, ¶ms[..]) @@ -100,7 +100,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("pins.remove"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/reactions.rs b/src/sync/mods/reactions.rs index cbc2de7f..dbf14559 100644 --- a/src/sync/mods/reactions.rs +++ b/src/sync/mods/reactions.rs @@ -40,7 +40,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reactions.add"); client .send(&url, ¶ms[..]) @@ -79,7 +79,7 @@ where .full .map(|full| ("full", if full { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reactions.get"); client .send(&url, ¶ms[..]) @@ -114,7 +114,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reactions.list"); client .send(&url, ¶ms[..]) @@ -151,7 +151,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reactions.remove"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/reminders.rs b/src/sync/mods/reminders.rs index 7f04ad6a..f8f6244e 100644 --- a/src/sync/mods/reminders.rs +++ b/src/sync/mods/reminders.rs @@ -34,7 +34,7 @@ where Some(("time", &time[..])), request.user.map(|user| ("user", user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reminders.add"); client .send(&url, ¶ms[..]) @@ -59,7 +59,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("reminder", request.reminder))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reminders.complete"); client .send(&url, ¶ms[..]) @@ -84,7 +84,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("reminder", request.reminder))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reminders.delete"); client .send(&url, ¶ms[..]) @@ -109,7 +109,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("reminder", request.reminder))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("reminders.info"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/rtm.rs b/src/sync/mods/rtm.rs index 89b8e64e..a1337516 100644 --- a/src/sync/mods/rtm.rs +++ b/src/sync/mods/rtm.rs @@ -68,7 +68,7 @@ where .include_locale .map(|include_locale| ("include_locale", if include_locale { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("rtm.start"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/search.rs b/src/sync/mods/search.rs index 080fff4c..352ed883 100644 --- a/src/sync/mods/search.rs +++ b/src/sync/mods/search.rs @@ -42,7 +42,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("search.all"); client .send(&url, ¶ms[..]) @@ -79,7 +79,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("search.files"); client .send(&url, ¶ms[..]) @@ -116,7 +116,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("search.messages"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/stars.rs b/src/sync/mods/stars.rs index 0338dc14..c113fe3c 100644 --- a/src/sync/mods/stars.rs +++ b/src/sync/mods/stars.rs @@ -39,7 +39,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("stars.add"); client .send(&url, ¶ms[..]) @@ -70,7 +70,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("stars.list"); client .send(&url, ¶ms[..]) @@ -106,7 +106,7 @@ where .as_ref() .map(|timestamp| ("timestamp", ×tamp[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("stars.remove"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/team.rs b/src/sync/mods/team.rs index 99a1f8be..a9e8d2ce 100644 --- a/src/sync/mods/team.rs +++ b/src/sync/mods/team.rs @@ -36,7 +36,7 @@ where page.as_ref().map(|page| ("page", &page[..])), before.as_ref().map(|before| ("before", &before[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("team.accessLogs"); client .send(&url, ¶ms[..]) @@ -64,7 +64,7 @@ where Some(("token", token)), request.user.map(|user| ("user", user)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("team.billableInfo"); client .send(&url, ¶ms[..]) @@ -123,7 +123,7 @@ where count.as_ref().map(|count| ("count", &count[..])), page.as_ref().map(|page| ("page", &page[..])), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("team.integrationLogs"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/team_profile.rs b/src/sync/mods/team_profile.rs index 916f525c..b7fc8c4f 100644 --- a/src/sync/mods/team_profile.rs +++ b/src/sync/mods/team_profile.rs @@ -33,7 +33,7 @@ where .visibility .map(|visibility| ("visibility", visibility)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("team.profile.get"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/usergroups.rs b/src/sync/mods/usergroups.rs index b181e6b3..4e326912 100644 --- a/src/sync/mods/usergroups.rs +++ b/src/sync/mods/usergroups.rs @@ -41,7 +41,7 @@ where .include_count .map(|include_count| ("include_count", if include_count { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.create"); client .send(&url, ¶ms[..]) @@ -72,7 +72,7 @@ where .include_count .map(|include_count| ("include_count", if include_count { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.disable"); client .send(&url, ¶ms[..]) @@ -103,7 +103,7 @@ where .include_count .map(|include_count| ("include_count", if include_count { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.enable"); client .send(&url, ¶ms[..]) @@ -139,7 +139,7 @@ where .include_users .map(|include_users| ("include_users", if include_users { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.list"); client .send(&url, ¶ms[..]) @@ -176,7 +176,7 @@ where .include_count .map(|include_count| ("include_count", if include_count { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.update"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/usergroups_users.rs b/src/sync/mods/usergroups_users.rs index 4889693f..37538db5 100644 --- a/src/sync/mods/usergroups_users.rs +++ b/src/sync/mods/usergroups_users.rs @@ -34,7 +34,7 @@ where .include_disabled .map(|include_disabled| ("include_disabled", if include_disabled { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.users.list"); client .send(&url, ¶ms[..]) @@ -66,7 +66,7 @@ where .include_count .map(|include_count| ("include_count", if include_count { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("usergroups.users.update"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/users.rs b/src/sync/mods/users.rs index 1c2d2fac..fd6d8b0f 100644 --- a/src/sync/mods/users.rs +++ b/src/sync/mods/users.rs @@ -53,7 +53,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("user", request.user))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.getPresence"); client .send(&url, ¶ms[..]) @@ -98,7 +98,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("user", request.user))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.info"); client .send(&url, ¶ms[..]) @@ -128,7 +128,7 @@ where .presence .map(|presence| ("presence", if presence { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.list"); client .send(&url, ¶ms[..]) @@ -173,7 +173,7 @@ where R: SlackWebRequestSender, { let params = vec![Some(("token", token)), Some(("presence", request.presence))]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.setPresence"); client .send(&url, ¶ms[..]) diff --git a/src/sync/mods/users_profile.rs b/src/sync/mods/users_profile.rs index 72776180..68ddafef 100644 --- a/src/sync/mods/users_profile.rs +++ b/src/sync/mods/users_profile.rs @@ -34,7 +34,7 @@ where .include_labels .map(|include_labels| ("include_labels", if include_labels { "1" } else { "0" })), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.profile.get"); client .send(&url, ¶ms[..]) @@ -65,7 +65,7 @@ where request.name.map(|name| ("name", name)), request.value.map(|value| ("value", value)), ]; - let params = params.into_iter().filter_map(|x| x).collect::>(); + let params = params.into_iter().flatten().collect::>(); let url = crate::get_slack_url_for_method("users.profile.set"); client .send(&url, ¶ms[..]) diff --git a/src/sync/requests.rs b/src/sync/requests.rs index 217fe8a1..434fc71b 100644 --- a/src/sync/requests.rs +++ b/src/sync/requests.rs @@ -45,7 +45,7 @@ mod reqwest_support { url.query_pairs_mut().extend_pairs(params); - Ok(self.get(url).send()?.text()?) + self.get(url).send()?.text() } } diff --git a/src/timestamp.rs b/src/timestamp.rs index b3686df3..9fe3ee92 100644 --- a/src/timestamp.rs +++ b/src/timestamp.rs @@ -67,7 +67,7 @@ impl<'de> ::serde::Deserialize<'de> for Timestamp { } else { Err(D::Error::custom(format!( "expected a timestamp but got: {}", - value.to_string() + value ))) } } diff --git a/src/types.rs b/src/types.rs index a183fa8c..fa9517b4 100644 --- a/src/types.rs +++ b/src/types.rs @@ -264,137 +264,137 @@ impl<'de> ::serde::Deserialize<'de> for Message { match ty { "standard" => ::serde_json::from_value::(value.clone()) .map(Message::Standard) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "bot_add" => ::serde_json::from_value::(value.clone()) .map(Message::BotAdd) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "bot_disable" => ::serde_json::from_value::(value.clone()) .map(Message::BotDisable) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "bot_enable" => ::serde_json::from_value::(value.clone()) .map(Message::BotEnable) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "bot_remove" => ::serde_json::from_value::(value.clone()) .map(Message::BotRemove) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "bot_message" => ::serde_json::from_value::(value.clone()) .map(Message::BotMessage) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "channel_archive" => { ::serde_json::from_value::(value.clone()) .map(Message::ChannelArchive) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "channel_join" => ::serde_json::from_value::(value.clone()) .map(Message::ChannelJoin) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "channel_leave" => { ::serde_json::from_value::(value.clone()) .map(Message::ChannelLeave) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "channel_name" => ::serde_json::from_value::(value.clone()) .map(Message::ChannelName) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "channel_purpose" => { ::serde_json::from_value::(value.clone()) .map(Message::ChannelPurpose) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "channel_topic" => { ::serde_json::from_value::(value.clone()) .map(Message::ChannelTopic) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "channel_unarchive" => { ::serde_json::from_value::(value.clone()) .map(Message::ChannelUnarchive) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "file_comment" => ::serde_json::from_value::(value.clone()) .map(Message::FileComment) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "file_mention" => ::serde_json::from_value::(value.clone()) .map(Message::FileMention) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "file_share" => ::serde_json::from_value::(value.clone()) .map(Message::FileShare) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "group_archive" => { ::serde_json::from_value::(value.clone()) .map(Message::GroupArchive) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "group_join" => ::serde_json::from_value::(value.clone()) .map(Message::GroupJoin) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "group_leave" => ::serde_json::from_value::(value.clone()) .map(Message::GroupLeave) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "group_name" => ::serde_json::from_value::(value.clone()) .map(Message::GroupName) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "group_purpose" => { ::serde_json::from_value::(value.clone()) .map(Message::GroupPurpose) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "group_topic" => ::serde_json::from_value::(value.clone()) .map(Message::GroupTopic) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "group_unarchive" => { ::serde_json::from_value::(value.clone()) .map(Message::GroupUnarchive) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "me_message" => ::serde_json::from_value::(value.clone()) .map(Message::MeMessage) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "message_changed" => { ::serde_json::from_value::(value.clone()) .map(Message::MessageChanged) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "message_deleted" => { ::serde_json::from_value::(value.clone()) .map(Message::MessageDeleted) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "message_replied" => { ::serde_json::from_value::(value.clone()) .map(Message::MessageReplied) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "pinned_item" => ::serde_json::from_value::(value.clone()) .map(Message::PinnedItem) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "reminder_add" => ::serde_json::from_value::(value.clone()) .map(Message::ReminderAdd) - .map_err(|e| D::Error::custom(&format!("{}", e))), + .map_err(|e| D::Error::custom(format!("{}", e))), "reply_broadcast" => { ::serde_json::from_value::(value.clone()) .map(Message::ReplyBroadcast) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "thread_broadcast" => { ::serde_json::from_value::(value.clone()) .map(Message::ThreadBroadcast) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "unpinned_item" => { ::serde_json::from_value::(value.clone()) .map(Message::UnpinnedItem) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "sh_room_created" => { ::serde_json::from_value::(value.clone()) .map(Message::ShRoomCreated) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } "slackbot_response" => { ::serde_json::from_value::(value.clone()) .map(Message::SlackbotResponse) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } _ => Err(D::Error::unknown_variant(ty, VARIANTS)), } @@ -407,7 +407,7 @@ impl<'de> ::serde::Deserialize<'de> for Message { } else { ::serde_json::from_value::(value.clone()) .map(Message::Standard) - .map_err(|e| D::Error::custom(&format!("{}", e))) + .map_err(|e| D::Error::custom(format!("{}", e))) } } } diff --git a/tests/smoke_test.rs b/tests/smoke_test.rs index 262df9a7..615e73f7 100644 --- a/tests/smoke_test.rs +++ b/tests/smoke_test.rs @@ -49,7 +49,7 @@ async fn smoke_channels() -> Result<(), Box> { .channels .ok_or("Expected some channels")?; - assert!(all_channels.len() > 0); + assert!(!all_channels.is_empty()); for channel in &all_channels[..10] { let channel_id = channel.id.as_ref().ok_or("expected channel id")?; @@ -58,7 +58,7 @@ async fn smoke_channels() -> Result<(), Box> { &client, &token, &slack::channels::InfoRequest { - channel: &channel_id, + channel: channel_id, ..Default::default() }, ) @@ -72,7 +72,7 @@ async fn smoke_channels() -> Result<(), Box> { &client, &token, &slack::channels::HistoryRequest { - channel: &channel_id, + channel: channel_id, oldest: Some(1234567890.1234.into()), ..Default::default() },