Trait gear_common::storage::Queue

source ·
pub trait Queue {
    type Value;
    type Error: DequeueError;
    type OutputError: From<Self::Error>;

    // Required methods
    fn dequeue() -> Result<Option<Self::Value>, Self::OutputError>;
    fn mutate_values<F: FnMut(Self::Value) -> Self::Value>(f: F);
    fn queue(value: Self::Value) -> Result<(), Self::OutputError>;
    fn clear();
    fn requeue(value: Self::Value) -> Result<(), Self::OutputError>;
}
Expand description

Represents message queue managing logic.

Required Associated Types§

source

type Value

Stored values type.

source

type Error: DequeueError

Inner error type of queue storing algorithm.

source

type OutputError: From<Self::Error>

Output error type of the queue.

Required Methods§

source

fn dequeue() -> Result<Option<Self::Value>, Self::OutputError>

Removes and returns message from the beginning of the queue, if present,

source

fn mutate_values<F: FnMut(Self::Value) -> Self::Value>(f: F)

Mutates all values in queue with given function.

source

fn queue(value: Self::Value) -> Result<(), Self::OutputError>

Inserts given value at the end of the queue.

source

fn clear()

Removes all values from queue.

source

fn requeue(value: Self::Value) -> Result<(), Self::OutputError>

Inserts given value at the beginning of the queue.

Should be used only for cases, when message was dequeued and it’s execution should be postponed until the next block.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T, OutputError, KeyGen> Queue for QueueImpl<T, OutputError, KeyGen>
where T: Dequeue, OutputError: From<T::Error>, T::Error: DequeueError, KeyGen: KeyFor<Key = T::Key, Value = T::Value>,

§

type Value = <T as Dequeue>::Value

§

type Error = <T as Dequeue>::Error

§

type OutputError = OutputError