diff --git a/src/base.rs b/src/base.rs index 524be17..0afb6e7 100644 --- a/src/base.rs +++ b/src/base.rs @@ -336,6 +336,31 @@ pub trait BaseExt: AsBase { self.base_ref().kind.as_ref() } + /// Check if the provide Kind is equal to the object's Kind + /// + /// ```rust + /// # fn main() -> Result<(), anyhow::Error> { + /// use activitystreams_new::{base::Base, prelude::*}; + /// + /// #[derive(PartialEq, serde::Deserialize)] + /// pub enum ValidKinds { + /// Video, + /// Image, + /// } + /// + /// let video: Base = serde_json::from_str(r#"{"type":"Video"}"#)?; + /// + /// assert!(video.is_kind(&ValidKinds::Video)); + /// # Ok(()) + /// # } + /// ``` + fn is_kind(&self, kind: &Kind) -> bool + where + Kind: PartialEq, + { + self.kind() == Some(kind) + } + /// Set the kind for the current object /// /// This overwrites the contents of kind