Add is_id to BaseExt

This commit is contained in:
asonix 2020-05-21 15:42:59 -05:00
parent f246e780d4
commit cbd6902978

View file

@ -263,6 +263,22 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
self.base_ref().id.as_ref() self.base_ref().id.as_ref()
} }
/// Check if the provided id is equal to the object's id
///
/// ```rust
/// # fn main() -> Result<(), anyhow::Error> {
/// use activitystreams_new::{object::Video, prelude::*};
///
/// let video: Video = serde_json::from_str(r#"{"type":"Video","id":"https://example.com"}"#)?;
///
/// assert!(video.is_id(&"https://example.com".parse()?));
/// # Ok(())
/// # }
/// ```
fn is_id(&self, id: &XsdAnyUri) -> bool {
self.id() == Some(id)
}
/// Set the id for the current object /// Set the id for the current object
/// ///
/// This overwrites the contents of id /// This overwrites the contents of id
@ -336,7 +352,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
self.base_ref().kind.as_ref() self.base_ref().kind.as_ref()
} }
/// Check if the provide Kind is equal to the object's Kind /// Check if the provided Kind is equal to the object's Kind
/// ///
/// ```rust /// ```rust
/// # fn main() -> Result<(), anyhow::Error> { /// # fn main() -> Result<(), anyhow::Error> {