summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-04-29 21:49:49 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-04-29 21:49:49 +0200
commit8aaa87a27358537246185c7284b7451b0b2d9bf7 (patch)
tree93d4960de6153cfe7d0bc6a8e0e34eaeb72e010f
parentbe71f0b4b907ef1d1bbc4dfefad5b20d4b94bd92 (diff)
Add checker methods what enum variant is there
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/types/payload.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/types/payload.rs b/src/types/payload.rs
index da4b95f..8a7de71 100644
--- a/src/types/payload.rs
+++ b/src/types/payload.rs
@@ -248,3 +248,32 @@ pub enum LoadedPayload {
},
}
+impl LoadedPayload {
+ pub fn is_none(&self) -> bool {
+ match self {
+ &LoadedPayload::None => true,
+ _ => false,
+ }
+ }
+
+ pub fn is_post(&self) -> bool {
+ match self {
+ &LoadedPayload::Post { .. }=> true,
+ _ => false,
+ }
+ }
+
+ pub fn is_attached_post_comments(&self) -> bool {
+ match self {
+ &LoadedPayload::AttachedPostComments { .. } => true,
+ _ => false,
+ }
+ }
+
+ pub fn is_profile(&self) -> bool {
+ match self {
+ &LoadedPayload::Profile { .. } => true,
+ _ => false,
+ }
+ }
+}