pub trait CountedByKey {
    type Key;
    type Length: Default + PartialEq;

    // Required method
    fn len(key: &Self::Key) -> Self::Length;

    // Provided method
    fn is_empty(key: &Self::Key) -> bool { ... }
}
Expand description

Represents default counting logic, by providing ability to return length of the object as specified (associated) type or answer the question is the object empty, by provided key of specified (associated) type.

Should be implemented on double map based types.

Required Associated Types§

source

type Key

Key type of counting target.

source

type Length: Default + PartialEq

Returning length type.

Required Methods§

source

fn len(key: &Self::Key) -> Self::Length

Returns current Self’s amount of elements as Length type.

Provided Methods§

source

fn is_empty(key: &Self::Key) -> bool

Returns bool, defining if Self doesn’t contain elements.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T, Task, Error, OutputError, Callbacks> CountedByKey for TaskPoolImpl<T, Task, Error, OutputError, Callbacks>
where T: DoubleMapStorage<Key2 = Task, Value = ()> + CountedByKey<Key = T::Key1>, Error: TaskPoolError, OutputError: From<Error>, Callbacks: TaskPoolCallbacks,

§

type Key = <T as DoubleMapStorage>::Key1

§

type Length = <T as CountedByKey>::Length

source§

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

§

type Key = <T as DoubleMapStorage>::Key1

§

type Length = <T as CountedByKey>::Length

source§

impl<T, Value, BlockNumber, Error, OutputError, Callbacks, KeyGen> CountedByKey for WaitlistImpl<T, Value, BlockNumber, Error, OutputError, Callbacks, KeyGen>
where T: DoubleMapStorage<Value = (Value, Interval<BlockNumber>)> + CountedByKey<Key = T::Key1>, Error: WaitlistError, OutputError: From<Error>, Callbacks: WaitlistCallbacks<Value = Value, BlockNumber = BlockNumber>, KeyGen: KeyFor<Key = (T::Key1, T::Key2), Value = Value>,

§

type Key = <T as DoubleMapStorage>::Key1

§

type Length = <T as CountedByKey>::Length