pub struct Sender<M: 'static> { /* private fields */ }
Expand description
Wraps a CanSend. This should be used to pass around an Arc<dyn CanSend
Implementations§
Source§impl<M> Sender<M>
impl<M> Sender<M>
Sourcepub fn send(&self, message: M)
pub fn send(&self, message: M)
Sends a message. It’s the responsibility of the underlying CanSend implementation to decide how to handle the message.
Sourcepub fn from_fn(send: impl Fn(M) + Send + Sync + 'static) -> Self
pub fn from_fn(send: impl Fn(M) + Send + Sync + 'static) -> Self
Creates a sender that handles messages using the given function.
Sourcepub fn break_apart(self) -> BreakApart<M>
pub fn break_apart(self) -> BreakApart<M>
Creates an object that implements CanSend<Inner>
for any message Inner
that can be converted to M
.
Source§impl<M, R: Send + 'static> Sender<MessageWithCallback<M, R>>
impl<M, R: Send + 'static> Sender<MessageWithCallback<M, R>>
Sourcepub fn send_async(
&self,
message: M,
) -> BoxFuture<'static, Result<R, AsyncSendError>>
pub fn send_async( &self, message: M, ) -> BoxFuture<'static, Result<R, AsyncSendError>>
Same as the above, but for a concrete Sender type.
Sourcepub fn from_async_fn(
send_async: impl Fn(M) -> R + Send + Sync + 'static,
) -> Self
pub fn from_async_fn( send_async: impl Fn(M) -> R + Send + Sync + 'static, ) -> Self
Creates a sender that would handle send_async messages by producing a result synchronously. Note that the provided function is NOT async.
(Implementing the similar functionality with async function is possible but requires deciding who drives the async function; a FutureSpawner can be a good idea.)
Trait Implementations§
Auto Trait Implementations§
impl<M> Freeze for Sender<M>
impl<M> !RefUnwindSafe for Sender<M>
impl<M> Send for Sender<M>
impl<M> Sync for Sender<M>
impl<M> Unpin for Sender<M>
impl<M> !UnwindSafe for Sender<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<A, B> IntoMultiSender<B> for Awhere
B: MultiSenderFrom<A>,
impl<A, B> IntoMultiSender<B> for Awhere
B: MultiSenderFrom<A>,
fn as_multi_sender(self: &Arc<A>) -> B
fn into_multi_sender(self) -> B
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request