[][src]Trait activitystreams::collection::CollectionExt

pub trait CollectionExt<Kind>: AsCollection<Kind> {
    fn items<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>>
    where
        Kind: 'a
, { ... }
fn set_items<T>(&mut self, item: T) -> &mut Self
    where
        T: Into<AnyBase>
, { ... }
fn set_many_items<I, T>(&mut self, items: I) -> &mut Self
    where
        I: IntoIterator<Item = T>,
        T: Into<AnyBase>
, { ... }
fn add_items<T>(&mut self, item: T) -> &mut Self
    where
        T: Into<AnyBase>
, { ... }
fn take_items(&mut self) -> Option<OneOrMany<AnyBase>> { ... }
fn delete_items(&mut self) -> &mut Self { ... }
fn total_items<'a>(&'a self) -> Option<u64>
    where
        Kind: 'a
, { ... }
fn set_total_items<T>(&mut self, total_items: T) -> &mut Self
    where
        T: Into<u64>
, { ... }
fn take_total_items(&mut self) -> Option<u64> { ... }
fn delete_total_items(&mut self) -> &mut Self { ... }
fn current<'a>(&'a self) -> Option<&'a AnyBase>
    where
        Kind: 'a
, { ... }
fn set_current<T>(&mut self, current: T) -> &mut Self
    where
        T: Into<AnyBase>
, { ... }
fn take_current(&mut self) -> Option<AnyBase> { ... }
fn delete_current(&mut self) -> &mut Self { ... }
fn first<'a>(&'a self) -> Option<&'a AnyBase>
    where
        Kind: 'a
, { ... }
fn set_first<T>(&mut self, first: T) -> &mut Self
    where
        T: Into<AnyBase>
, { ... }
fn take_first(&mut self) -> Option<AnyBase> { ... }
fn delete_first(&mut self) -> &mut Self { ... }
fn last<'a>(&'a self) -> Option<&'a AnyBase>
    where
        Kind: 'a
, { ... }
fn set_last<T>(&mut self, last: T) -> &mut Self
    where
        T: Into<AnyBase>
, { ... }
fn take_last(&mut self) -> Option<AnyBase> { ... }
fn delete_last(&mut self) -> &mut Self { ... } }

Helper methods for interacting with Collection types

This trait represents methods valid for any ActivityStreams Collection

Documentation for the fields related to these methods can be found on the Collection struct

Provided methods

fn items<'a>(&'a self) -> Option<&'a OneOrMany<AnyBase>> where
    Kind: 'a, 

Fetch the items for the current activity

use activitystreams::prelude::*;

let items_ref = collection.items();
println!("{:?}", items_ref);

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

Set the items for the current activity

This overwrites the contents of items

use activitystreams::prelude::*;

collection.set_items(uri!("https://example.com"));

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

Set many itemss for the current activity

This overwrites the contents of items

use activitystreams::prelude::*;

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

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

Add a items to the current activity

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

use activitystreams::prelude::*;

collection
    .add_items(uri!("https://example.com/one"))
    .add_items(uri!("https://example.com/two"));

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

Take the items of the current object, leaving nothing

use activitystreams::prelude::*;

if let Some(items) = collection.take_items() {
    println!("{:?}", items);
}

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

Delete the items from the current object

use activitystreams::prelude::*;

assert!(collection.items().is_some());
collection.delete_items();
assert!(collection.items().is_none());

fn total_items<'a>(&'a self) -> Option<u64> where
    Kind: 'a, 

Fetch the total_items of the current object

use activitystreams::prelude::*;

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

fn set_total_items<T>(&mut self, total_items: T) -> &mut Self where
    T: Into<u64>, 

Set the total_items for the current object

This overwrites the contents of total_items

use activitystreams::prelude::*;

collection.set_total_items(5u64);

fn take_total_items(&mut self) -> Option<u64>

Take the total_items of the current object, leaving nothing

use activitystreams::prelude::*;

if let Some(total_items) = collection.take_total_items() {
    println!("{:?}", total_items);
}

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

Delete the total_items from the current object

use activitystreams::prelude::*;

assert!(collection.total_items().is_some());
collection.delete_total_items();
assert!(collection.total_items().is_none());

fn current<'a>(&'a self) -> Option<&'a AnyBase> where
    Kind: 'a, 

Fetch the current field for the current object

use activitystreams::prelude::*;

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

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

Set the current field for the current object

This overwrites the contents of current

use activitystreams::prelude::*;

collection.set_current(uri!("https://example.com"));

fn take_current(&mut self) -> Option<AnyBase>

Take the current field from the current object, leaving nothing

use activitystreams::prelude::*;

if let Some(current) = collection.take_current() {
    println!("{:?}", current);
}

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

Delete the current field from the current object

use activitystreams::prelude::*;

assert!(collection.current().is_some());
collection.delete_current();
assert!(collection.current().is_none());

fn first<'a>(&'a self) -> Option<&'a AnyBase> where
    Kind: 'a, 

Fetch the first field for the current object

use activitystreams::prelude::*;

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

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

Set the first field for the current object

This overwrites the contents of first

use activitystreams::{prelude::*, uri};

collection.set_first(uri!("https://example.com"));

fn take_first(&mut self) -> Option<AnyBase>

Take the first field from the current object, leaving nothing

use activitystreams::prelude::*;

if let Some(first) = collection.take_first() {
    println!("{:?}", first);
}

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

Delete the first field from the current object

use activitystreams::prelude::*;

assert!(collection.first().is_some());
collection.delete_first();
assert!(collection.first().is_none());

fn last<'a>(&'a self) -> Option<&'a AnyBase> where
    Kind: 'a, 

Fetch the last field for the current object

use activitystreams::prelude::*;

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

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

Set the last field for the current object

This overwrites the contents of last

use activitystreams::{prelude::*, uri};

collection.set_last(uri!("https://example.com"));

fn take_last(&mut self) -> Option<AnyBase>

Take the last field from the current object, leaving nothing

use activitystreams::prelude::*;

if let Some(last) = collection.take_last() {
    println!("{:?}", last);
}

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

Delete the last field from the current object

use activitystreams::prelude::*;

assert!(collection.last().is_some());
collection.delete_last();
assert!(collection.last().is_none());
Loading content...

Implementors

impl<T, Kind> CollectionExt<Kind> for T where
    T: AsCollection<Kind>, 
[src]

Loading content...