Add is_id to BaseExt
This commit is contained in:
parent
f246e780d4
commit
cbd6902978
1 changed files with 17 additions and 1 deletions
18
src/base.rs
18
src/base.rs
|
@ -263,6 +263,22 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
|||
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
|
||||
///
|
||||
/// This overwrites the contents of id
|
||||
|
@ -336,7 +352,7 @@ pub trait BaseExt<Kind>: AsBase<Kind> {
|
|||
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
|
||||
/// # fn main() -> Result<(), anyhow::Error> {
|
||||
|
|
Loading…
Reference in a new issue