macro_rules! delegate_get {
($type:ident) => {
impl<T: super::GetRenderable> super::GetRenderable for $type<T> {
type Get = T::Get;
#[inline]
fn get(&mut self) -> Result<Self::Get, coap_message_utils::Error> {
self.0.get()
}
}
};
}
macro_rules! delegate_post {
($type:ident) => {
impl<T: super::PostRenderable> super::PostRenderable for $type<T> {
type PostIn = T::PostIn;
type PostOut = T::PostOut;
#[inline]
fn post(
&mut self,
representation: &Self::PostIn,
) -> Result<Self::PostOut, coap_message_utils::Error> {
self.0.post(representation)
}
}
};
}
macro_rules! delegate_put {
($type:ident) => {
impl<T: super::PutRenderable> super::PutRenderable for $type<T> {
type Put = T::Put;
#[inline]
fn put(&mut self, representation: &Self::Put) -> Result<(), coap_message_utils::Error> {
self.0.put(representation)
}
}
};
}
macro_rules! delegate_delete {
($type:ident) => {
impl<T: super::DeleteRenderable> super::DeleteRenderable for $type<T> {
#[inline]
fn delete(&mut self) -> Result<(), coap_message_utils::Error> {
self.0.delete()
}
}
};
}
macro_rules! delegate_fetch {
($type:ident) => {
impl<T: super::FetchRenderable> super::FetchRenderable for $type<T> {
type FetchIn = T::FetchIn;
type FetchOut = T::FetchOut;
#[inline]
fn fetch(
&mut self,
representation: &Self::FetchIn,
) -> Result<Self::FetchOut, coap_message_utils::Error> {
self.0.fetch(representation)
}
}
};
}
macro_rules! delegate_ipatch {
($type:ident) => {
impl<T: super::IPatchRenderable> super::IPatchRenderable for $type<T> {
type IPatch = T::IPatch;
#[inline]
fn ipatch(
&mut self,
representation: &Self::IPatch,
) -> Result<(), coap_message_utils::Error> {
self.0.ipatch(representation)
}
}
};
}
pub struct FillGet<T>(pub(crate) T);
impl<T> super::GetRenderable for FillGet<T> {
type Get = ();
}
delegate_post!(FillGet);
delegate_put!(FillGet);
delegate_delete!(FillGet);
delegate_fetch!(FillGet);
delegate_ipatch!(FillGet);
impl<
T: super::PostRenderable
+ super::PutRenderable
+ super::DeleteRenderable
+ super::FetchRenderable
+ super::IPatchRenderable,
> super::TypeRenderable for FillGet<T>
{
}
pub struct FillPost<T>(pub(crate) T);
delegate_get!(FillPost);
impl<T> super::PostRenderable for FillPost<T> {
type PostIn = ();
type PostOut = ();
}
delegate_put!(FillPost);
delegate_delete!(FillPost);
delegate_fetch!(FillPost);
delegate_ipatch!(FillPost);
impl<
T: super::GetRenderable
+ super::PutRenderable
+ super::DeleteRenderable
+ super::FetchRenderable
+ super::IPatchRenderable,
> super::TypeRenderable for FillPost<T>
{
}
pub struct FillPut<T>(pub(crate) T);
delegate_get!(FillPut);
delegate_post!(FillPut);
impl<T> super::PutRenderable for FillPut<T> {
type Put = ();
}
delegate_delete!(FillPut);
delegate_fetch!(FillPut);
delegate_ipatch!(FillPut);
impl<
T: super::GetRenderable
+ super::PostRenderable
+ super::DeleteRenderable
+ super::FetchRenderable
+ super::IPatchRenderable,
> super::TypeRenderable for FillPut<T>
{
}
pub struct FillDelete<T>(pub(crate) T);
delegate_get!(FillDelete);
delegate_post!(FillDelete);
delegate_put!(FillDelete);
impl<T> super::DeleteRenderable for FillDelete<T> {
}
delegate_fetch!(FillDelete);
delegate_ipatch!(FillDelete);
impl<
T: super::GetRenderable
+ super::PostRenderable
+ super::PutRenderable
+ super::FetchRenderable
+ super::IPatchRenderable,
> super::TypeRenderable for FillDelete<T>
{
}
pub struct FillFetch<T>(pub(crate) T);
delegate_get!(FillFetch);
delegate_post!(FillFetch);
delegate_put!(FillFetch);
delegate_delete!(FillFetch);
impl<T> super::FetchRenderable for FillFetch<T> {
type FetchIn = ();
type FetchOut = ();
}
delegate_ipatch!(FillFetch);
impl<
T: super::GetRenderable
+ super::PostRenderable
+ super::PutRenderable
+ super::DeleteRenderable
+ super::IPatchRenderable,
> super::TypeRenderable for FillFetch<T>
{
}
pub struct FillIPatch<T>(pub(crate) T);
delegate_get!(FillIPatch);
delegate_post!(FillIPatch);
delegate_put!(FillIPatch);
delegate_delete!(FillIPatch);
delegate_fetch!(FillIPatch);
impl<T> super::IPatchRenderable for FillIPatch<T> {
type IPatch = ();
}
impl<
T: super::GetRenderable
+ super::PostRenderable
+ super::PutRenderable
+ super::DeleteRenderable
+ super::FetchRenderable,
> super::TypeRenderable for FillIPatch<T>
{
}