Struct near_async::messaging::LateBoundSender
source · pub struct LateBoundSender<S> { /* private fields */ }
Expand description
Sometimes we want to be able to pass in a sender that has not yet been fully constructed. LateBoundSender can act as a placeholder to pass CanSend and CanSendAsync capabilities through to the inner object. bind() should be called when the inner object is ready. All calls to send() and send_async() through this wrapper will block until bind() is called.
This struct is intended to be wrapped with an Arc, e.g. let late_bound = Arc::new(LateBoundSender::default()); let something_else = SomethingElse::new(late_bound.as_sender()); let implementation = Implementation::new(something_else); late_bound.bind(implementation);
Implementations§
source§impl<S> LateBoundSender<S>
impl<S> LateBoundSender<S>
Trait Implementations§
source§impl<M, S: CanSend<M>> CanSend<M> for LateBoundSender<S>
impl<M, S: CanSend<M>> CanSend<M> for LateBoundSender<S>
Allows LateBoundSender to be convertible to a Sender as long as the inner object could be.
source§impl<M, R, S: CanSendAsync<M, R>> CanSendAsync<M, R> for LateBoundSender<S>
impl<M, R, S: CanSendAsync<M, R>> CanSendAsync<M, R> for LateBoundSender<S>
Allows LateBoundSender to be convertible to an AsyncSender as long as the inner object could be.
fn send_async(&self, message: M) -> BoxFuture<'static, R>
Auto Trait Implementations§
impl<S> RefUnwindSafe for LateBoundSender<S>where S: UnwindSafe + RefUnwindSafe,
impl<S> Send for LateBoundSender<S>where S: Send,
impl<S> Sync for LateBoundSender<S>where S: Send + Sync,
impl<S> Unpin for LateBoundSender<S>where S: Unpin,
impl<S> UnwindSafe for LateBoundSender<S>where S: UnwindSafe,
Blanket Implementations§
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§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<M, R, T> IntoAsyncSender<M, R> for Twhere
T: CanSendAsync<M, R>,
impl<M, R, T> IntoAsyncSender<M, R> for Twhere T: CanSendAsync<M, R>,
source§fn into_async_sender(self) -> AsyncSender<M, R>
fn into_async_sender(self) -> AsyncSender<M, R>
source§fn as_async_sender(self: &Arc<T>) -> AsyncSender<M, R>
fn as_async_sender(self: &Arc<T>) -> AsyncSender<M, R>
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