Trait gear_common::storage::Mailbox

source ·
pub trait Mailbox {
    type Key1;
    type Key2;
    type Value;
    type BlockNumber;
    type Error: MailboxError;
    type OutputError: From<Self::Error>;

    // Required methods
    fn contains(key1: &Self::Key1, key2: &Self::Key2) -> bool;
    fn insert(
        value: Self::Value,
        bn: Self::BlockNumber,
    ) -> Result<(), Self::OutputError>;
    fn remove(
        key1: Self::Key1,
        key2: Self::Key2,
    ) -> Result<(Self::Value, Interval<Self::BlockNumber>), Self::OutputError>;
    fn peek(key1: &Self::Key1, key2: &Self::Key2) -> Option<Self::Value>;
    fn clear();
}
Expand description

Represents mailbox managing logic.

Required Associated Types§

source

type Key1

First key type.

source

type Key2

Second key type.

source

type Value

Stored values type.

source

type BlockNumber

Block number type.

Stored with Self::Value.

source

type Error: MailboxError

Inner error type of mailbox storing algorithm.

source

type OutputError: From<Self::Error>

Output error type of the mailbox.

Required Methods§

source

fn contains(key1: &Self::Key1, key2: &Self::Key2) -> bool

Returns bool, defining does first key’s mailbox contain second key.

source

fn insert( value: Self::Value, bn: Self::BlockNumber, ) -> Result<(), Self::OutputError>

Inserts given value in mailbox.

source

fn remove( key1: Self::Key1, key2: Self::Key2, ) -> Result<(Self::Value, Interval<Self::BlockNumber>), Self::OutputError>

Removes and returns value from mailbox by given keys, if present, else returns error.

source

fn peek(key1: &Self::Key1, key2: &Self::Key2) -> Option<Self::Value>

Peeks into the mailbox using the given keys to return a message, if present. Does not destroy the message.

source

fn clear()

Removes all values from all key’s mailboxes.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T, Value, BlockNumber, Error, OutputError, Callbacks, KeyGen> Mailbox for MailboxImpl<T, Value, BlockNumber, Error, OutputError, Callbacks, KeyGen>
where T: DoubleMapStorage<Value = (Value, Interval<BlockNumber>)>, Error: MailboxError, OutputError: From<Error>, Callbacks: MailboxCallbacks<OutputError, Value = Value, BlockNumber = BlockNumber>, KeyGen: KeyFor<Key = (T::Key1, T::Key2), Value = Value>,

§

type Key1 = <T as DoubleMapStorage>::Key1

§

type Key2 = <T as DoubleMapStorage>::Key2

§

type Value = Value

§

type BlockNumber = BlockNumber

§

type Error = Error

§

type OutputError = OutputError