Trait bee_tangle::Hooks[][src]

pub trait Hooks<T> {
    type Error: Debug;
    #[must_use]
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        message_id: &'life1 MessageId
    ) -> Pin<Box<dyn Future<Output = Result<Option<(Message, T)>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn insert<'life0, 'async_trait>(
        &'life0 self,
        message_id: MessageId,
        msg: Message,
        metadata: T
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn fetch_approvers<'life0, 'life1, 'async_trait>(
        &'life0 self,
        message_id: &'life1 MessageId
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<MessageId>>, Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn insert_approver<'life0, 'async_trait>(
        &'life0 self,
        message_id: MessageId,
        approver: MessageId
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn update_approvers<'life0, 'life1, 'async_trait>(
        &'life0 self,
        message_id: MessageId,
        approvers: &'life1 [MessageId]
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; }
Expand description

A trait used to provide hooks for a tangle. The tangle acts as an in-memory cache and will use hooks to extend its effective volume. When an entry doesn’t exist in the tangle cache and needs fetching, or when an entry gets inserted, the tangle will call out to the hooks in order to fulfil these actions.

Associated Types

type Error: Debug[src]

Expand description

An error generated by these hooks.

Loading content...

Required methods

#[must_use]
fn get<'life0, 'life1, 'async_trait>(
    &'life0 self,
    message_id: &'life1 MessageId
) -> Pin<Box<dyn Future<Output = Result<Option<(Message, T)>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Expand description

Fetch a message from some external storage medium.

#[must_use]
fn insert<'life0, 'async_trait>(
    &'life0 self,
    message_id: MessageId,
    msg: Message,
    metadata: T
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Expand description

Insert a message into some external storage medium.

#[must_use]
fn fetch_approvers<'life0, 'life1, 'async_trait>(
    &'life0 self,
    message_id: &'life1 MessageId
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<MessageId>>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Expand description

Fetch the approvers list for a given message.

#[must_use]
fn insert_approver<'life0, 'async_trait>(
    &'life0 self,
    message_id: MessageId,
    approver: MessageId
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Expand description

Insert a new approver for a given message.

#[must_use]
fn update_approvers<'life0, 'life1, 'async_trait>(
    &'life0 self,
    message_id: MessageId,
    approvers: &'life1 [MessageId]
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Expand description

Update the approvers list for a given message.

Loading content...

Implementors

impl<B: StorageBackend> Hooks<MessageMetadata> for StorageHooks<B>[src]

type Error = B::Error

fn get<'life0, 'life1, 'async_trait>(
    &'life0 self,
    id: &'life1 MessageId
) -> Pin<Box<dyn Future<Output = Result<Option<(Message, MessageMetadata)>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

fn insert<'life0, 'async_trait>(
    &'life0 self,
    id: MessageId,
    tx: Message,
    metadata: MessageMetadata
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn fetch_approvers<'life0, 'life1, 'async_trait>(
    &'life0 self,
    id: &'life1 MessageId
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<MessageId>>, Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

fn insert_approver<'life0, 'async_trait>(
    &'life0 self,
    id: MessageId,
    approver: MessageId
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

fn update_approvers<'life0, 'life1, 'async_trait>(
    &'life0 self,
    id: MessageId,
    approvers: &'life1 [MessageId]
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Loading content...