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§

Fetch the result for the current activity

use activitystreams::prelude::*;

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

Set the result for the current activity

This overwrites the contents of result

use activitystreams::prelude::*;

question.set_result(iri!("https://example.com"));

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"),
]);

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"));

Take the result from the current activity, leaving nothing

use activitystreams::prelude::*;

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

Delete the result from the current activity

use activitystreams::prelude::*;

assert!(question.result().is_some());
question.delete_result();
assert!(question.result().is_none());

Fetch the instrument for the current activity

use activitystreams::prelude::*;

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

Set the instrument for the current activity

This overwrites the contents of instrument

use activitystreams::prelude::*;

question.set_instrument(iri!("https://example.com"));

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"),
]);

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"));

Take the instrument from the current activity, leaving nothing

use activitystreams::prelude::*;

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

Delete the instrument from the current activity

use activitystreams::prelude::*;

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

Implementors§