Struct near_async::test_loop::delay_sender::DelaySender
source · pub struct DelaySender<Event>(/* private fields */);Expand description
Interface to send an event with a delay (in virtual time). It can be converted to a Sender for any message type that can be converted into the event type, so that a DelaySender given by the test loop may be passed to production code that expects a Sender.
Implementations§
source§impl<Event> DelaySender<Event>
impl<Event> DelaySender<Event>
pub fn new(inner: impl Fn(Event, Duration) + Send + Sync + 'static) -> Self
pub fn send_with_delay(&self, event: Event, delay: Duration)
pub fn with_additional_delay(&self, delay: Duration) -> DelaySender<Event>where
Event: 'static,
pub fn narrow<InnerEvent>(self) -> DelaySender<InnerEvent>where
Event: From<InnerEvent> + 'static,
sourcepub fn into_wrapped_multi_sender<M: 'static, S: 'static>(self) -> S
pub fn into_wrapped_multi_sender<M: 'static, S: 'static>(self) -> S
A shortcut for a common use case, where we use an enum message to represent all the possible messages that a multisender may be used to send.
This assumes that S is a multisender with the derive
#[derive(MultiSendMessage, ...)], which creates the enum
MyMultiSenderMessage (where MyMultiSender is the name of the struct
being derived from).
To use, first include in the test loop event enum a case for
MyMultiSenderMessage. Then, call this function to get a multisender,
like
builder.wrapped_multi_sender<MyMultiSenderMessage, MyMultiSender>().
pub fn into_delayed_action_runner<InnerData>(
self,
shutting_down: Arc<AtomicBool>,
) -> TestLoopDelayedActionRunner<InnerData>where
Event: From<TestLoopDelayedActionEvent<InnerData>> + 'static,
sourcepub fn into_future_spawner(self) -> TestLoopFutureSpawner
pub fn into_future_spawner(self) -> TestLoopFutureSpawner
Returns a FutureSpawner that can be used to spawn futures into the loop.
sourcepub fn into_async_computation_spawner(
self,
artificial_delay: impl Fn(&str) -> Duration + Send + Sync + 'static,
) -> TestLoopAsyncComputationSpawnerwhere
Event: From<TestLoopAsyncComputationEvent> + 'static,
pub fn into_async_computation_spawner(
self,
artificial_delay: impl Fn(&str) -> Duration + Send + Sync + 'static,
) -> TestLoopAsyncComputationSpawnerwhere
Event: From<TestLoopAsyncComputationEvent> + 'static,
Returns an AsyncComputationSpawner that can be used to spawn async computation into the
loop. The artificial_delay allows the test to determine an artificial delay that the
computation should take, based on the name of the computation.
source§impl<Event: 'static> DelaySender<(usize, Event)>
impl<Event: 'static> DelaySender<(usize, Event)>
sourcepub fn for_index(self, index: usize) -> DelaySender<Event>
pub fn for_index(self, index: usize) -> DelaySender<Event>
Converts a multi-instance sender to a single-instance sender.
Trait Implementations§
source§impl<Data: 'static, Event: From<AdhocEvent<Data>> + 'static> AdhocEventSender<Data> for DelaySender<Event>
impl<Data: 'static, Event: From<AdhocEvent<Data>> + 'static> AdhocEventSender<Data> for DelaySender<Event>
source§impl<Message, Event: From<Message> + 'static> CanSend<Message> for DelaySender<Event>
impl<Message, Event: From<Message> + 'static> CanSend<Message> for DelaySender<Event>
Auto Trait Implementations§
impl<Event> Freeze for DelaySender<Event>
impl<Event> !RefUnwindSafe for DelaySender<Event>
impl<Event> Send for DelaySender<Event>
impl<Event> Sync for DelaySender<Event>
impl<Event> Unpin for DelaySender<Event>
impl<Event> !UnwindSafe for DelaySender<Event>
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)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> FutureSpawnerExt for Twhere
T: FutureSpawner,
impl<T> FutureSpawnerExt for Twhere
T: FutureSpawner,
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