Trait activitypub_federation::traits::Collection

source ·
pub trait Collection: Sized {
    type Owner;
    type DataType: Clone + Send + Sync;
    type Kind: for<'de2> Deserialize<'de2>;
    type Error;

    // Required methods
    fn read_local<'life0, 'life1, 'async_trait>(
        owner: &'life0 Self::Owner,
        data: &'life1 Data<Self::DataType>,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Kind, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn verify<'life0, 'life1, 'life2, 'async_trait>(
        json: &'life0 Self::Kind,
        expected_domain: &'life1 Url,
        data: &'life2 Data<Self::DataType>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn from_json<'life0, 'life1, 'async_trait>(
        json: Self::Kind,
        owner: &'life0 Self::Owner,
        data: &'life1 Data<Self::DataType>,
    ) -> Pin<Box<dyn Future<Output = Result<Self, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Trait for federating collections

Required Associated Types§

source

type Owner

Actor or object that this collection belongs to

source

type DataType: Clone + Send + Sync

App data type passed to handlers. Must be identical to crate::config::FederationConfigBuilder::app_data type.

source

type Kind: for<'de2> Deserialize<'de2>

The type of protocol struct which gets sent over network to federate this database struct.

source

type Error

Error type returned by handler methods

Required Methods§

source

fn read_local<'life0, 'life1, 'async_trait>( owner: &'life0 Self::Owner, data: &'life1 Data<Self::DataType>, ) -> Pin<Box<dyn Future<Output = Result<Self::Kind, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reads local collection from database and returns it as Activitypub JSON.

source

fn verify<'life0, 'life1, 'life2, 'async_trait>( json: &'life0 Self::Kind, expected_domain: &'life1 Url, data: &'life2 Data<Self::DataType>, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Verifies that the received object is valid.

You should check here that the domain of id matches expected_domain. Additionally you should perform any application specific checks.

source

fn from_json<'life0, 'life1, 'async_trait>( json: Self::Kind, owner: &'life0 Self::Owner, data: &'life1 Data<Self::DataType>, ) -> Pin<Box<dyn Future<Output = Result<Self, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Convert object from ActivityPub type to database type.

Called when an object is received from HTTP fetch or as part of an activity. This method should also write the received object to database. Note that there is no distinction between create and update, so an upsert operation should be used.

Object Safety§

This trait is not object safe.

Implementors§