diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-04-29 21:49:49 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-04-29 21:49:49 +0200 |
commit | 8aaa87a27358537246185c7284b7451b0b2d9bf7 (patch) | |
tree | 93d4960de6153cfe7d0bc6a8e0e34eaeb72e010f | |
parent | be71f0b4b907ef1d1bbc4dfefad5b20d4b94bd92 (diff) |
Add checker methods what enum variant is there
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/types/payload.rs | 29 |
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, + } + } +} |