Trait LocalCallback

Source
pub trait LocalCallback<T>: Debug + Ord {
    // Required method
    async fn run(self, response: T);
}
Expand description

A callback to process the result of a request.

Sometimes, we may fetch the same object for multiple purposes, so a request may have more than one callback registered. For example, we may fetch a leaf for its own sake and also to reconstruct a block. Or, we may fetch the same payload for two different blocks. In both of these cases, there are two objects that must be processed and stored after the fetch completes.

In these cases, we only want one task to actually fetch the resource, but there may be several unrelated actions to take after the resource is fetched. This trait allows us to identify a callback, so that when the task that actually fetched the resource completes, it will run one instance of each distinct callback which was registered. Callbacks will run in the order determined by Ord.

Required Methods§

Source

async fn run(self, response: T)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, TraitVariantBlanketType: Callback<T>> LocalCallback<T> for TraitVariantBlanketType