Trait activitystreams::activity::ActivityExt
source · pub trait ActivityExt: AsActivity {
fn result<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
where
Self::Kind: 'a,
{ ... }
fn set_result<T>(&mut self, result: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
fn set_many_results<I, T>(&mut self, items: I) -> &mut Self
where
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
{ ... }
fn add_result<T>(&mut self, result: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
fn take_result(&mut self) -> Option<OneOrMany<AnyBase>> { ... }
fn delete_result(&mut self) -> &mut Self { ... }
fn instrument<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
where
Self::Kind: 'a,
{ ... }
fn set_instrument<T>(&mut self, instrument: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
fn set_many_instruments<I, T>(&mut self, items: I) -> &mut Self
where
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
{ ... }
fn add_instrument<T>(&mut self, instrument: T) -> &mut Self
where
T: Into<AnyBase>,
{ ... }
fn take_instrument(&mut self) -> Option<OneOrMany<AnyBase>> { ... }
fn delete_instrument(&mut self) -> &mut Self { ... }
}
Expand description
Helper methods for interacting with Activity types
This trait represents methods valid for any ActivityStreams Activity
Documentation for the fields related to these methods can be found on the Activity
struct
Provided Methods§
sourcefn result<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>where
Self::Kind: 'a,
fn result<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>where
Self::Kind: 'a,
Fetch the result for the current activity
use activitystreams::prelude::*;
if let Some(result) = question.result() {
println!("{:?}", result);
}
sourcefn set_result<T>(&mut self, result: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn set_result<T>(&mut self, result: T) -> &mut Selfwhere
T: Into<AnyBase>,
Set the result for the current activity
This overwrites the contents of result
use activitystreams::prelude::*;
question.set_result(iri!("https://example.com"));
sourcefn set_many_results<I, T>(&mut self, items: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
fn set_many_results<I, T>(&mut self, items: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
Set many results for the current activity
This overwrites the contents of result
use activitystreams::prelude::*;
question.set_many_results(vec![
iri!("https://example.com/one"),
iri!("https://example.com/two"),
]);
sourcefn add_result<T>(&mut self, result: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn add_result<T>(&mut self, result: T) -> &mut Selfwhere
T: Into<AnyBase>,
Add a result to the current activity
This does not overwrite the contents of result, only appends an item
use activitystreams::{prelude::*, iri};
question
.add_result(iri!("https://example.com/one"))
.add_result(iri!("https://example.com/two"));
sourcefn take_result(&mut self) -> Option<OneOrMany<AnyBase>>
fn take_result(&mut self) -> Option<OneOrMany<AnyBase>>
Take the result from the current activity, leaving nothing
use activitystreams::prelude::*;
if let Some(result) = question.take_result() {
println!("{:?}", result);
}
sourcefn delete_result(&mut self) -> &mut Self
fn delete_result(&mut self) -> &mut Self
Delete the result from the current activity
use activitystreams::prelude::*;
assert!(question.result().is_some());
question.delete_result();
assert!(question.result().is_none());
sourcefn instrument<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>where
Self::Kind: 'a,
fn instrument<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>where
Self::Kind: 'a,
Fetch the instrument for the current activity
use activitystreams::prelude::*;
if let Some(instrument) = question.instrument() {
println!("{:?}", instrument);
}
sourcefn set_instrument<T>(&mut self, instrument: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn set_instrument<T>(&mut self, instrument: T) -> &mut Selfwhere
T: Into<AnyBase>,
Set the instrument for the current activity
This overwrites the contents of instrument
use activitystreams::prelude::*;
question.set_instrument(iri!("https://example.com"));
sourcefn set_many_instruments<I, T>(&mut self, items: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
fn set_many_instruments<I, T>(&mut self, items: I) -> &mut Selfwhere
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
Set many instruments for the current activity
This overwrites the contents of instrument
use activitystreams::prelude::*;
question.set_many_instruments(vec![
iri!("https://example.com/one"),
iri!("https://example.com/two"),
]);
sourcefn add_instrument<T>(&mut self, instrument: T) -> &mut Selfwhere
T: Into<AnyBase>,
fn add_instrument<T>(&mut self, instrument: T) -> &mut Selfwhere
T: Into<AnyBase>,
Add a instrument to the current activity
This does not overwrite the contents of instrument, only appends an item
use activitystreams::prelude::*;
question
.add_instrument(iri!("https://example.com/one"))
.add_instrument(iri!("https://example.com/two"));
sourcefn take_instrument(&mut self) -> Option<OneOrMany<AnyBase>>
fn take_instrument(&mut self) -> Option<OneOrMany<AnyBase>>
Take the instrument from the current activity, leaving nothing
use activitystreams::prelude::*;
if let Some(instrument) = question.take_instrument() {
println!("{:?}", instrument);
}
sourcefn delete_instrument(&mut self) -> &mut Self
fn delete_instrument(&mut self) -> &mut Self
Delete the instrument from the current activity
use activitystreams::prelude::*;
assert!(question.instrument().is_some());
question.delete_instrument();
assert!(question.instrument().is_none());