use std::pin::Pin;
#[cfg(feature = "type-erased-recipient-hook")]
use std::any::Any;
use tokio::time::Duration;
use crate::actor::ActorId;
use crate::channel::oneshot::Receiver;
use crate::envelope::DefaultEnvelopeProxy;
use crate::errors::SendError;
use crate::message::Message;
pub type SendResult<M> = Result<Receiver<<M as Message>::Result>, SendError<M>>;
pub type SendResultFuture<'a, M> = Pin<
Box<dyn Future<Output = Result<Receiver<<M as Message>::Result>, SendError<M>>> + Send + 'a>,
>;
pub type DoSendResult<M> = Result<(), SendError<M>>;
pub type DoSendResultFuture<'a, M> =
Pin<Box<dyn Future<Output = Result<(), SendError<M>>> + Send + 'a>>;
pub type ClosedResultFuture<'a> = Pin<Box<dyn Future<Output = ()> + Send + 'a>>;
pub trait SenderId {
fn index(&self) -> ActorId;
#[cfg(feature = "ipc")]
#[cfg_attr(docsrs, doc(cfg(feature = "ipc")))]
#[inline]
fn is_remote(&self) -> bool {
self.index() >> 63 != 0
}
}
impl SenderId for ActorId {
#[inline]
fn index(&self) -> ActorId {
*self
}
}
pub trait Sender<M, EP = DefaultEnvelopeProxy<M>>: SenderId
where
M: Message,
{
fn closed(&self) -> ClosedResultFuture<'_>;
fn is_closed(&self) -> bool;
fn capacity(&self) -> usize;
fn send(&self, msg: M) -> SendResultFuture<'_, M>;
fn do_send(&self, msg: M) -> DoSendResultFuture<'_, M>;
fn try_send(&self, msg: M) -> SendResult<M>;
fn try_do_send(&self, msg: M) -> DoSendResult<M>;
fn send_timeout(&self, msg: M, timeout: Duration) -> SendResultFuture<'_, M>;
fn do_send_timeout(&self, msg: M, timeout: Duration) -> DoSendResultFuture<'_, M>;
fn blocking_send(&self, msg: M) -> SendResult<M>;
fn blocking_do_send(&self, msg: M) -> DoSendResult<M>;
#[cfg(feature = "type-erased-recipient-hook")]
#[cfg_attr(docsrs, doc(cfg(feature = "type-erased-recipient-hook")))]
fn type_erased_recipient(&self) -> Option<Box<dyn Any + Send + Sync>> {
None
}
}