Skip to main content

Consumer

Trait Consumer 

Source
pub trait Consumer:
    Clone
    + Send
    + 'static {
    type Key: Span;
    type Value;
    type Subscriber: Clone + Eq + Send + 'static;
    type Outcome: Into<Outcome> + Send + 'static;

    // Required method
    fn deliver(
        &mut self,
        delivery: Delivery<Self::Key, Self::Subscriber>,
        value: Self::Value,
    ) -> Receiver<Self::Outcome> ⓘ;
}
Expand description

Determines the disposition of data returned for a fetch.

Required Associated Types§

Source

type Key: Span

Type used to key data requested from peers.

Source

type Value

Type of data to retrieve.

Source

type Subscriber: Clone + Eq + Send + 'static

Type used to track subscribers on fetch keys.

Source

type Outcome: Into<Outcome> + Send + 'static

Delivery disposition returned after validation.

Consumers that only distinguish valid and invalid data may use bool, which maps true to Resolved(Resolution::Complete) and false to Invalid.

Required Methods§

Source

fn deliver( &mut self, delivery: Delivery<Self::Key, Self::Subscriber>, value: Self::Value, ) -> Receiver<Self::Outcome> ⓘ

Deliver data to the consumer.

Returns a receiver that reports whether the response completes the delivery, is invalid, is valid but leaves subscribers unresolved, or can be ignored because the key is no longer needed.

Removing the last subscriber cancels the delivery. A verdict sent before the receiver closes still contributes source feedback, but cannot complete or retry a later fetch for the same key.

If all delivered subscribers were already satisfied without this response, drop the verdict sender. Dropping the sender retires only the delivered subscribers, without crediting or penalizing the source. Any remaining subscribers receive the same response.

Implementations of Resolver must only invoke deliver for keys that were previously requested via Resolver::fetch (or TargetedResolver variants).

delivery contains the peer-visible key and the retained subscribers for the fetch. Subscribers decide who should observe a valid response; they do not define peer validity.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§