use crate :: { *, import::* };
pub trait Address<M>: Identify
where Self: Sink<M> + fmt::Debug + Unpin + Send ,
M : Message ,
<Self as Sink<M>>::Error: std::error::Error + Send + Sync + 'static ,
{
#[ must_use = "Futures do nothing unless polled" ]
fn call( &mut self, msg: M ) -> Return<'_, Result< <M as Message>::Return, <Self as Sink<M> >::Error >>;
fn clone_box( &self ) -> BoxAddress<M, <Self as Sink<M> >::Error>;
fn as_address( &self ) -> &dyn Address<M, Error = <Self as Sink<M> >::Error>
where Self: Sized,
{
self
}
}
impl<M, T> Address<M> for Box<T>
where M: Message ,
T: Address<M> + Identify + ?Sized ,
T: Sink<M> + fmt::Debug + Unpin + Send ,
<T as Sink<M>>::Error: std::error::Error + Send + Sync + 'static ,
{
#[ must_use = "Futures do nothing unless polled" ]
fn call( &mut self, msg: M ) -> Return<'_, Result< <M as Message>::Return, <T as Sink<M> >::Error >>
{
(**self).call( msg )
}
fn clone_box( &self ) -> BoxAddress<M, <T as Sink<M> >::Error>
{
(**self).clone_box()
}
}
impl<M, T> Address<M> for &mut T
where M: Message ,
T: Address<M> + Identify + ?Sized ,
T: Sink<M> + fmt::Debug + Unpin + Send ,
<T as Sink<M>>::Error: std::error::Error + Send + Sync + 'static ,
{
#[ must_use = "Futures do nothing unless polled" ]
fn call( &mut self, msg: M ) -> Return<'_, Result< <M as Message>::Return, <T as Sink<M> >::Error >>
{
(**self).call( msg )
}
fn clone_box( &self ) -> BoxAddress<M, <T as Sink<M> >::Error>
{
(**self).clone_box()
}
}