#[macro_export]
macro_rules! forward_bind {
($st:ty, $($field:tt),+ $(,)?) => {
#[inline]
fn bind(&self, ctx: $crate::BindCtx<'_>) {
$(ctx.bind::<_, $st, _>(&self.$field);)+
}
};
($st:ty, $this:ident.$field:tt) => {
#[inline]
fn bind(&$this, ctx: $crate::BindCtx<'_>) {
ctx.bind::<_, $st, _>(&$this.$field);
}
};
}
#[macro_export]
macro_rules! forward_pl_bind {
($st:ty, $($field:tt),+ $(,)?) => {
#[inline]
fn bind(&self, ctx: $crate::BindCtx<'_>) {
$(self.$field.bind_to(&ctx);)+
}
};
($st:ty, $this:ident.$field:tt) => {
#[inline]
fn bind(&$this, ctx: $crate::BindCtx<'_>) {
$this.$field.bind_to(&ctx);
}
};
}
#[macro_export]
macro_rules! forward_ready {
($st:ty, $field:ident) => {
#[inline]
async fn ready(&self, ctx: $crate::Ctx<'_, Self, $st>) -> Result<(), Self::Error> {
ctx.ready(&self.$field)
.await
.map_err(::core::convert::Into::into)
}
};
($st:ty, $field:ident, $err:expr) => {
#[inline]
async fn ready(&self, ctx: $crate::Ctx<'_, Self, $st>) -> Result<(), Self::Error> {
ctx.ready(&self.$field).await.map_err($err)
}
};
($st:ty, $this:ident.$field:tt) => {
#[inline]
async fn ready(&$this, ctx: $crate::Ctx<'_, Self, $st>) -> Result<(), Self::Error> {
ctx.ready(&$this.$field)
.await
.map_err(::core::convert::Into::into)
}
};
($st:ty, $this:ident.$field:tt, $err:expr) => {
#[inline]
async fn ready(&$this, ctx: $crate::Ctx<'_, Self, $st>) -> Result<(), Self::Error> {
ctx.ready(&$this.$field).await.map_err($err)
}
};
}
#[macro_export]
macro_rules! forward_shutdown {
($st:ty, $field:ident) => {
#[inline]
async fn shutdown(&self, ctx: $crate::Ctx<'_, Self, $st>) {
ctx.shutdown(&self.$field).await
}
};
($st:ty, $this:ident.$field:tt) => {
#[inline]
async fn shutdown(&$this, ctx: $crate::Ctx<'_, Self, $st>) {
ctx.shutdown(&$this.$field).await
}
};
}
#[macro_export]
macro_rules! forward_pl_ready {
($st:ty, $field:ident) => {
#[inline]
async fn ready(&self, _: $crate::Ctx<'_, Self, $st>) -> Result<(), Self::Error> {
self.$field
.ready()
.await
.map_err(::core::convert::Into::into)
}
};
($st:ty, $field:ident, $err:expr) => {
#[inline]
async fn ready(&self, _: $crate::Ctx<'_, Self, $st>) -> Result<(), Self::Error> {
self.$field.ready().await.map_err($err)
}
};
($st:ty, $this:ident.$field:ident) => {
#[inline]
async fn ready(&$this, _: $crate::Ctx<'_, Self, $st>) -> Result<(), Self::Error> {
$this
.$field
.ready()
.await
.map_err(::core::convert::Into::into)
}
};
($st:ty, $this:ident.$field:ident, $err:expr) => {
#[inline]
async fn ready(&$this, _: $crate::Ctx<'_, Self, $st>) -> Result<(), Self::Error> {
$this.$field.ready().await.map_err($err)
}
};
}
#[macro_export]
macro_rules! forward_pl_shutdown {
($st:ty, $field:ident) => {
#[inline]
async fn shutdown(&self, _: $crate::Ctx<'_, Self, $st>) {
self.$field.shutdown().await
}
};
($st:ty, $this:ident.$field:tt) => {
#[inline]
async fn shutdown(&$this, _: $crate::Ctx<'_, Self, $st>) {
$this.$field.shutdown().await
}
};
}