[−][src]Trait activitystreams::activity::ActivityExt
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
fn result<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>> where
Kind: 'a,
Kind: 'a,
Fetch the result for the current activity
use activitystreams::prelude::*; if let Some(result) = question.result() { println!("{:?}", result); }
fn set_result<T>(&mut self, result: T) -> &mut Self where
T: Into<AnyBase>,
T: Into<AnyBase>,
Set the result for the current activity
This overwrites the contents of result
use activitystreams::prelude::*; question.set_result(uri!("https://example.com"));
fn set_many_results<I, T>(&mut self, items: I) -> &mut Self where
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
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![ uri!("https://example.com/one"), uri!("https://example.com/two"), ]);
fn add_result<T>(&mut self, result: T) -> &mut Self where
T: Into<AnyBase>,
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::*, uri}; question .add_result(uri!("https://example.com/one")) .add_result(uri!("https://example.com/two"));
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); }
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());
fn instrument<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>> where
Kind: 'a,
Kind: 'a,
Fetch the instrument for the current activity
use activitystreams::prelude::*; if let Some(instrument) = question.instrument() { println!("{:?}", instrument); }
fn set_instrument<T>(&mut self, instrument: T) -> &mut Self where
T: Into<AnyBase>,
T: Into<AnyBase>,
Set the instrument for the current activity
This overwrites the contents of instrument
use activitystreams::prelude::*; question.set_instrument(uri!("https://example.com"));
fn set_many_instruments<I, T>(&mut self, items: I) -> &mut Self where
I: IntoIterator<Item = T>,
T: Into<AnyBase>,
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![ uri!("https://example.com/one"), uri!("https://example.com/two"), ]);
fn add_instrument<T>(&mut self, instrument: T) -> &mut Self where
T: Into<AnyBase>,
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(uri!("https://example.com/one")) .add_instrument(uri!("https://example.com/two"));
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); }
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());
Implementors
impl<T, Kind> ActivityExt<Kind> for T where
T: AsActivity<Kind>,
[src]
T: AsActivity<Kind>,