[][src]Crate activitystreams_traits

Traits for Activity Streams

These traits don't provide any functionality other than anotations for types created in other projects. See the activitystreams-types crate for examples of how these traits could be used.

Examples

use activitystreams_traits::{Object, Actor};
use serde::{Deserialize, Serialize};
use std::any::Any;

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Persona {
    #[serde(rename = "@context")]
    context: String,

    #[serde(rename = "type")]
    kind: String,
}

#[typetag::serde]
impl Object for Persona {
    fn as_any(&self) -> &(dyn Any + 'static) {
        self
    }

    fn as_any_mut(&mut self) -> &mut (dyn Any + 'static) {
        self
    }

    fn duplicate(&self) -> Box<dyn Object + 'static> {
        Box::new(self.clone())
    }
}
impl Actor for Persona {}

Traits

Activity

An Activity is a subtype of Object that describes some form of action that may happen, is currently happening, or has already happened.

Actor

Actor types are Object types that are capable of performing activities.

Collection

A Collection is a subtype of Object that represents ordered or unordered sets of Object or Link instances.

CollectionPage

Used to represent distinct subsets of items from a Collection.

IntransitiveActivity

Instances of IntransitiveActivity are a subtype of Activity representing intransitive actions.

Link

A Link is an indirect, qualified reference to a resource identified by a URL.

Object

Describes an object of any kind.