Trait activitystreams::activity::AsActivityActorExt
source · pub trait AsActivityActorExt: AsActivityActor {
fn actor(&self) -> Result<&OneOrMany<AnyBase>, CheckError>
where
Self: BaseExt,
{ ... }
fn actor_unchecked(&self) -> &OneOrMany<AnyBase> { ... }
fn actor_is(&self, id: &IriString) -> bool { ... }
fn set_actor<T>(&mut self, actor: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
fn set_many_actors<I, T>(&mut self, items: I) -> &mut Self
where
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
{ ... }
fn add_actor<T>(&mut self, actor: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
}
Expand description
Helper methods for interacting with Activity types with actor and object fields
Documentation for the fields related to these methods can be found on the
ActorAndObject
struct
Provided Methods§
sourcefn actor(&self) -> Result<&OneOrMany<AnyBase>, CheckError>where
Self: BaseExt,
fn actor(&self) -> Result<&OneOrMany<AnyBase>, CheckError>where
Self: BaseExt,
Fetch the actor for the current activity
use activitystreams::prelude::*;
let actor_ref = create.actor();
println!("{:?}", actor_ref);
sourcefn actor_unchecked(&self) -> &OneOrMany<AnyBase>
fn actor_unchecked(&self) -> &OneOrMany<AnyBase>
Fetch the actor for the current activity
use activitystreams::prelude::*;
let actor_ref = create.actor_unchecked();
println!("{:?}", actor_ref);
sourcefn actor_is(&self, id: &IriString) -> bool
fn actor_is(&self, id: &IriString) -> bool
Check if the actor’s ID is id
use activitystreams::prelude::*;
create.set_actor(iri!("https://example.com"));
assert!(create.actor_is(&iri!("https://example.com")));
sourcefn set_actor<T>(&mut self, actor: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn set_actor<T>(&mut self, actor: T) -> &mut Selfwhere
T: Into<AnyBase>,
Set the actor for the current activity
This overwrites the contents of actor
use activitystreams::prelude::*;
create.set_actor(iri!("https://example.com"));
sourcefn set_many_actors<I, T>(&mut self, items: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
fn set_many_actors<I, T>(&mut self, items: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
Set many actors for the current activity
This overwrites the contents of actor
use activitystreams::prelude::*;
create.set_many_actors(vec![
iri!("https://example.com/one"),
iri!("https://example.com/two"),
]);
sourcefn add_actor<T>(&mut self, actor: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn add_actor<T>(&mut self, actor: T) -> &mut Selfwhere
T: Into<AnyBase>,
Add a actor to the current activity
This does not overwrite the contents of actor, only appends an item
use activitystreams::prelude::*;
create
.add_actor(iri!("https://example.com/one"))
.add_actor(iri!("https://example.com/two"));