[][src]Trait activitystreams_new::activity::ActivityExt

pub trait ActivityExt<Kind>: AsActivity<Kind> {
    fn result<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
    where
        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
        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 { ... } }

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, 

Fetch the result for the current activity

use activitystreams_new::prelude::*;

if let Some(result) = question.result() {
    println!("{:?}", result);
}

fn set_result<T>(&mut self, result: T) -> &mut Self where
    T: Into<AnyBase>, 

Set the result for the current activity

This overwrites the contents of result

use activitystreams_new::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>, 

Set many results for the current activity

This overwrites the contents of result

use activitystreams_new::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>, 

Add a result to the current activity

This does not overwrite the contents of result, only appends an item

use activitystreams_new::{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_new::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_new::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, 

Fetch the instrument for the current activity

use activitystreams_new::prelude::*;

if let Some(instrument) = question.instrument() {
    println!("{:?}", instrument);
}

fn set_instrument<T>(&mut self, instrument: T) -> &mut Self where
    T: Into<AnyBase>, 

Set the instrument for the current activity

This overwrites the contents of instrument

use activitystreams_new::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>, 

Set many instruments for the current activity

This overwrites the contents of instrument

use activitystreams_new::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>, 

Add a instrument to the current activity

This does not overwrite the contents of instrument, only appends an item

use activitystreams_new::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_new::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_new::prelude::*;

assert!(question.instrument().is_some());
question.delete_instrument();
assert!(question.instrument().is_none());
Loading content...

Implementors

impl<T, Kind> ActivityExt<Kind> for T where
    T: AsActivity<Kind>, 
[src]

Loading content...