diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-06-15 19:24:42 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-06-15 19:24:42 +0200 |
commit | 8739e1b7f0e422f0b0c8a146fa5ad302af831dff (patch) | |
tree | 90cce66d07d0578fba1ba640ef1f28b336c60ee4 /src/types/content.rs | |
parent | 93c440de45fe35951bdead563ec4477c88d156da (diff) |
Add helper functions for the Payload enum
Diffstat (limited to 'src/types/content.rs')
-rw-r--r-- | src/types/content.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/types/content.rs b/src/types/content.rs index 63bad91..3280757 100644 --- a/src/types/content.rs +++ b/src/types/content.rs @@ -190,6 +190,40 @@ pub enum Payload { }, } +impl Payload { + /// Helper function + pub fn is_none(&self) -> bool { + match self { + &Payload::None => true, + _ => false, + } + } + + /// Helper function + pub fn is_post(&self) -> bool { + match self { + &Payload::Post {..} => true, + _ => false, + } + } + + /// Helper function + pub fn is_attached_post_comments(&self) -> bool { + match self { + &Payload::AttachedPostComments {..} => true, + _ => false, + } + } + + /// Helper function + pub fn is_profile(&self) -> bool { + match self { + &Payload::Profile {..} => true, + _ => false, + } + } +} + #[derive(Serialize, Deserialize, Debug)] pub struct Userdata { #[serde(rename = "mimetype")] |