#[cfg(doc)]
use super::Set;
use super::{Merge, Unset};
pub trait Declaration {
type Headers;
type ProcessedAt;
type OwnFetch;
type OwnAck;
type OwnRetry;
type OwnDiscard;
type OwnRecover;
}
macro_rules! setting {
($(#[$doc:meta])* $name:ident, $slot:ident) => {
$(#[$doc])*
#[derive(Debug)]
pub struct $name;
impl Declaration for $name {
setting!(@slots $slot, Set<Self>;
Headers ProcessedAt OwnFetch OwnAck OwnRetry OwnDiscard OwnRecover);
}
};
(@slots $slot:ident, $value:ty; $($each:ident)*) => {
$(setting!(@slot $slot, $value; $each);)*
};
(@slot Headers, $value:ty; Headers) => { type Headers = $value; };
(@slot ProcessedAt, $value:ty; ProcessedAt) => { type ProcessedAt = $value; };
(@slot OwnFetch, $value:ty; OwnFetch) => { type OwnFetch = $value; };
(@slot OwnAck, $value:ty; OwnAck) => { type OwnAck = $value; };
(@slot OwnRetry, $value:ty; OwnRetry) => { type OwnRetry = $value; };
(@slot OwnDiscard, $value:ty; OwnDiscard) => { type OwnDiscard = $value; };
(@slot OwnRecover, $value:ty; OwnRecover) => { type OwnRecover = $value; };
(@slot $slot:ident, $value:ty; $other:ident) => { type $other = Unset; };
}
pub(super) use setting;
impl Declaration for () {
type Headers = Unset;
type ProcessedAt = Unset;
type OwnFetch = Unset;
type OwnAck = Unset;
type OwnRetry = Unset;
type OwnDiscard = Unset;
type OwnRecover = Unset;
}
macro_rules! tuple {
($head:ident $(, $tail:ident)*) => {
tuple!(@impl [$head $(, $tail)*] $head, ($($tail,)*);
Headers ProcessedAt OwnFetch OwnAck OwnRetry OwnDiscard OwnRecover);
};
(@impl [$($each:ident),*] $head:ident, $tail:ty; $($slot:ident)*) => {
impl<$($each: Declaration),*> Declaration for ($($each,)*)
where
$tail: Declaration,
$($head::$slot: Merge<<$tail as Declaration>::$slot>,)*
{
$(type $slot = <$head::$slot as Merge<<$tail as Declaration>::$slot>>::Out;)*
}
};
}
tuple!(Setting1);
tuple!(Setting1, Setting2);
tuple!(Setting1, Setting2, Setting3);
tuple!(Setting1, Setting2, Setting3, Setting4);
tuple!(Setting1, Setting2, Setting3, Setting4, Setting5);
tuple!(Setting1, Setting2, Setting3, Setting4, Setting5, Setting6);
tuple!(
Setting1, Setting2, Setting3, Setting4, Setting5, Setting6, Setting7
);
tuple!(
Setting1, Setting2, Setting3, Setting4, Setting5, Setting6, Setting7, Setting8
);