use crate::storage::{
Counted, CountedByKey, Counter, DequeueError, Interval, IterableByKeyMap, IterableMap, Mailbox,
MailboxError, MapStorage, Queue, Toggler, Waitlist, WaitlistError,
};
use core::fmt::Debug;
pub trait Messenger {
type BlockNumber;
type Capacity;
type Error: Debug + DequeueError + MailboxError + WaitlistError;
type OutputError: From<Self::Error> + Debug;
type MailboxFirstKey;
type MailboxSecondKey;
type MailboxedMessage;
type QueuedDispatch;
type WaitlistFirstKey;
type WaitlistSecondKey;
type WaitlistedMessage;
type DispatchStashKey;
type Sent: Counter<Value = Self::Capacity>;
type Dequeued: Counter<Value = Self::Capacity>;
type QueueProcessing: Toggler;
type Queue: Queue<Value = Self::QueuedDispatch, Error = Self::Error, OutputError = Self::OutputError>
+ Counted<Length = Self::Capacity>
+ IterableMap<Result<Self::QueuedDispatch, Self::OutputError>>;
type Mailbox: Mailbox<
Key1 = Self::MailboxFirstKey,
Key2 = Self::MailboxSecondKey,
Value = Self::MailboxedMessage,
BlockNumber = Self::BlockNumber,
Error = Self::Error,
OutputError = Self::OutputError,
> + CountedByKey<Key = Self::MailboxFirstKey, Length = usize>
+ IterableMap<(Self::MailboxedMessage, Interval<Self::BlockNumber>)>
+ IterableByKeyMap<
(Self::MailboxedMessage, Interval<Self::BlockNumber>),
Key = Self::MailboxFirstKey,
>;
type Waitlist: Waitlist<
Key1 = Self::WaitlistFirstKey,
Key2 = Self::WaitlistSecondKey,
Value = Self::WaitlistedMessage,
BlockNumber = Self::BlockNumber,
Error = Self::Error,
OutputError = Self::OutputError,
> + CountedByKey<Key = Self::WaitlistFirstKey, Length = usize>
+ IterableMap<(Self::WaitlistedMessage, Interval<Self::BlockNumber>)>
+ IterableByKeyMap<
(Self::WaitlistedMessage, Interval<Self::BlockNumber>),
Key = Self::WaitlistFirstKey,
>;
type DispatchStash: MapStorage<
Key = Self::DispatchStashKey,
Value = (Self::QueuedDispatch, Interval<Self::BlockNumber>),
>;
fn reset() {
Self::Sent::reset();
Self::Dequeued::reset();
Self::QueueProcessing::allow();
Self::Queue::clear();
Self::Mailbox::clear();
Self::Waitlist::clear();
Self::DispatchStash::clear();
}
}