[][src]Trait activitystreams_new::activity::OptTargetRefExt

pub trait OptTargetRefExt: OptTargetRef {
    fn target(&self) -> Option<&OneOrMany<AnyBase>> { ... }
fn set_target<T>(&mut self, target: T) -> &mut Self
    where
        T: Into<AnyBase>
, { ... }
fn set_many_targets<I, T>(&mut self, items: I) -> &mut Self
    where
        I: IntoIterator<Item = T>,
        T: Into<AnyBase>
, { ... }
fn add_target<T>(&mut self, target: T) -> &mut Self
    where
        T: Into<AnyBase>
, { ... }
fn take_target(&mut self) -> Option<OneOrMany<AnyBase>> { ... }
fn delete_target(&mut self) -> &mut Self { ... } }

Helper methods for interacting with Activity types with an optional target field

Documentation for the target field can be found on the ActorAndObjectOptTarget struct

Provided methods

fn target(&self) -> Option<&OneOrMany<AnyBase>>

Fetch the target for the current activity

use activitystreams_new::prelude::*;

if let Some(target_ref) = announce.target() {
    println!("{:?}", target_ref);
}

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

Set the target for the current activity

This overwrites the contents of target

use activitystreams_new::prelude::*;

announce.set_target(uri!("https://example.com"));

fn set_many_targets<I, T>(&mut self, items: I) -> &mut Self where
    I: IntoIterator<Item = T>,
    T: Into<AnyBase>, 

Set many targets for the current activity

This overwrites the contents of target

use activitystreams_new::prelude::*;

announce.set_many_targets(vec![
    uri!("https://example.com/one"),
    uri!("https://example.com/two"),
]);

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

Add a target to the current activity

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

use activitystreams_new::prelude::*;

announce
    .add_target(uri!("https://example.com/one"))
    .add_target(uri!("https://example.com/two"));

fn take_target(&mut self) -> Option<OneOrMany<AnyBase>>

Take a target from the current activity, leaving nothing

use activitystreams_new::prelude::*;

if let Some(target) = announce.take_target() {
    println!("{:?}", target);
}

fn delete_target(&mut self) -> &mut Self

Delete a target from the current activity

use activitystreams_new::prelude::*;

assert!(announce.target().is_some());
announce.delete_target();
assert!(announce.target().is_none());
Loading content...

Implementors

impl<T> OptTargetRefExt for T where
    T: OptTargetRef
[src]

Loading content...