FriendsStore

Trait FriendsStore 

Source
pub trait FriendsStore {
    // Required methods
    fn add_friend<'life0, 'async_trait>(
        &'life0 self,
        friend: Friend,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_friend<'life0, 'life1, 'async_trait>(
        &'life0 self,
        peer_id: &'life1 PeerId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Friend>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_friends<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Friend>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A trait for managing friends.

Required Methods§

Source

fn add_friend<'life0, 'async_trait>( &'life0 self, friend: Friend, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Adds a new friend to the store.

§Arguments
  • friend - The Friend to add.
§Errors

This function will return an error if the friend cannot be added.

Source

fn get_friend<'life0, 'life1, 'async_trait>( &'life0 self, peer_id: &'life1 PeerId, ) -> Pin<Box<dyn Future<Output = Result<Option<Friend>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves a friend from the store by their PeerId.

§Arguments
  • peer_id - The PeerId of the friend to retrieve.
§Returns

An Option containing the Friend if found, otherwise None.

§Errors

This function will return an error if the friend cannot be retrieved.

Source

fn list_friends<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Friend>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lists all friends in the store.

§Returns

A Vec containing all Friends in the store.

§Errors

This function will return an error if the friends cannot be listed.

Implementors§