[][src]Trait activitystreams_new::activity::OptOriginRefExt

pub trait OptOriginRefExt: OptOriginRef {
    fn origin(&self) -> Option<&OneOrMany<AnyBase>> { ... }
fn set_origin<T>(&mut self, origin: T) -> &mut Self
    where
        T: Into<AnyBase>
, { ... }
fn set_many_origins<I, T>(&mut self, items: I) -> &mut Self
    where
        I: IntoIterator<Item = T>,
        T: Into<AnyBase>
, { ... }
fn add_origin<T>(&mut self, origin: T) -> &mut Self
    where
        T: Into<AnyBase>
, { ... }
fn take_origin(&mut self) -> Option<OneOrMany<AnyBase>> { ... }
fn delete_origin(&mut self) -> &mut Self { ... } }

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

Documentation for the origin field can be found on the Delete struct

Provided methods

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

Fetch the origin for the current activity

use activitystreams_new::prelude::*;

if let Some(origin_ref) = delete.origin() {
    println!("{:?}", origin_ref);
}

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

Set the origin for the current activity

This overwrites the contents of origin

use activitystreams_new::prelude::*;

delete.set_origin(uri!("https://example.com"));

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

Set many origins for the current activity

This overwrites the contents of origin

use activitystreams_new::prelude::*;

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

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

Add a origin to the current activity

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

use activitystreams_new::prelude::*;

delete
    .add_origin(uri!("https://example.com/one"))
    .add_origin(uri!("https://example.com/two"));

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

Take a origin from the current activity, leaving nothing

use activitystreams_new::prelude::*;

if let Some(origin) = delete.take_origin() {
    println!("{:?}", origin);
}

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

Delete a origin from the current activity

use activitystreams_new::prelude::*;

assert!(delete.origin().is_some());
delete.delete_origin();
assert!(delete.origin().is_none());
Loading content...

Implementors

impl<T> OptOriginRefExt for T where
    T: OptOriginRef
[src]

Loading content...