Struct tor_rtmock::MockNetRuntime
source · [−]pub struct MockNetRuntime<R: Runtime> { /* private fields */ }
Expand description
A wrapper Runtime that overrides the SleepProvider trait for the underlying runtime.
Implementations
sourceimpl<R: Runtime> MockNetRuntime<R>
impl<R: Runtime> MockNetRuntime<R>
sourcepub fn new(runtime: R, net: MockNetProvider) -> Self
pub fn new(runtime: R, net: MockNetProvider) -> Self
Create a new runtime that wraps runtime
, but overrides
its view of the network with a MockNetProvider
, net
.
sourcepub fn mock_net(&self) -> &MockNetProvider
pub fn mock_net(&self) -> &MockNetProvider
Return a reference to the MockNetProvider
Trait Implementations
sourceimpl<R: Runtime> BlockOn for MockNetRuntime<R>
impl<R: Runtime> BlockOn for MockNetRuntime<R>
sourceimpl<R: Clone + Runtime> Clone for MockNetRuntime<R>
impl<R: Clone + Runtime> Clone for MockNetRuntime<R>
sourcefn clone(&self) -> MockNetRuntime<R>
fn clone(&self) -> MockNetRuntime<R>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<R: Debug + Runtime> Debug for MockNetRuntime<R>
impl<R: Debug + Runtime> Debug for MockNetRuntime<R>
sourceimpl<R: Runtime> SleepProvider for MockNetRuntime<R>
impl<R: Runtime> SleepProvider for MockNetRuntime<R>
type SleepFuture = <R as SleepProvider>::SleepFuture
type SleepFuture = <R as SleepProvider>::SleepFuture
A future returned by SleepProvider::sleep()
sourcefn sleep(&self, dur: Duration) -> Self::SleepFuture
fn sleep(&self, dur: Duration) -> Self::SleepFuture
Return a future that will be ready after duration
has
elapsed. Read more
sourcefn wallclock(&self) -> SystemTime
fn wallclock(&self) -> SystemTime
Return the SleepProvider’s view of the current wall-clock time. Read more
sourcefn block_advance<T>(&self, _reason: T) where
T: Into<String>,
fn block_advance<T>(&self, _reason: T) where
T: Into<String>,
Signify that a test running under mock time shouldn’t advance time yet, with a given unique reason string. This is useful for making sure (mock) time doesn’t advance while things that might require some (real-world) time to complete do so, such as spawning a task on another thread. Read more
sourcefn release_advance<T>(&self, _reason: T) where
T: Into<String>,
fn release_advance<T>(&self, _reason: T) where
T: Into<String>,
Signify that the reason to withhold time advancing provided in a call to block_advance
no
longer exists, and it’s fine to move time forward if nothing else is blocking advances. Read more
sourcefn allow_one_advance(&self, _dur: Duration)
fn allow_one_advance(&self, _dur: Duration)
Allow a test running under mock time to advance time by the provided duration, even if the
above block_advance
API has been used. Read more
sourceimpl<R: Runtime> Spawn for MockNetRuntime<R>
impl<R: Runtime> Spawn for MockNetRuntime<R>
sourceimpl<R: Runtime> TcpProvider for MockNetRuntime<R>
impl<R: Runtime> TcpProvider for MockNetRuntime<R>
type TcpStream = <MockNetProvider as TcpProvider>::TcpStream
type TcpStream = <MockNetProvider as TcpProvider>::TcpStream
The type for the TCP connections returned by Self::connect()
.
type TcpListener = <MockNetProvider as TcpProvider>::TcpListener
type TcpListener = <MockNetProvider as TcpProvider>::TcpListener
The type for the TCP listeners returned by Self::listen()
.
sourcefn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 SocketAddr
) -> Pin<Box<dyn Future<Output = IoResult<Self::TcpStream>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 SocketAddr
) -> Pin<Box<dyn Future<Output = IoResult<Self::TcpStream>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Launch a TCP connection to a given socket address. Read more
sourcefn listen<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 SocketAddr
) -> Pin<Box<dyn Future<Output = IoResult<Self::TcpListener>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn listen<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 SocketAddr
) -> Pin<Box<dyn Future<Output = IoResult<Self::TcpListener>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Open a TCP listener on a given socket address.
sourceimpl<R: Runtime> TlsProvider<LocalStream> for MockNetRuntime<R>
impl<R: Runtime> TlsProvider<LocalStream> for MockNetRuntime<R>
type Connector = <MockNetProvider as TlsProvider<LocalStream>>::Connector
type Connector = <MockNetProvider as TlsProvider<LocalStream>>::Connector
The Connector object that this provider can return.
type TlsStream = <MockNetProvider as TlsProvider<LocalStream>>::TlsStream
type TlsStream = <MockNetProvider as TlsProvider<LocalStream>>::TlsStream
The type of the stream returned by that connector.
sourcefn tls_connector(&self) -> Self::Connector
fn tls_connector(&self) -> Self::Connector
Return a TLS connector for use with this runtime.
sourceimpl<R: Runtime> UdpProvider for MockNetRuntime<R>
impl<R: Runtime> UdpProvider for MockNetRuntime<R>
type UdpSocket = <R as UdpProvider>::UdpSocket
type UdpSocket = <R as UdpProvider>::UdpSocket
The type of Udp Socket returned by Self::bind()
Auto Trait Implementations
impl<R> RefUnwindSafe for MockNetRuntime<R> where
R: RefUnwindSafe,
impl<R> Send for MockNetRuntime<R>
impl<R> Sync for MockNetRuntime<R>
impl<R> Unpin for MockNetRuntime<R> where
R: Unpin,
impl<R> UnwindSafe for MockNetRuntime<R> where
R: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> SleepProviderExt for T where
T: SleepProvider,
impl<T> SleepProviderExt for T where
T: SleepProvider,
sourcefn timeout<F>(
&self,
duration: Duration,
future: F
) -> Timeout<F, Self::SleepFuture> where
F: Future,
fn timeout<F>(
&self,
duration: Duration,
future: F
) -> Timeout<F, Self::SleepFuture> where
F: Future,
sourcefn sleep_until_wallclock(
&self,
when: SystemTime
) -> SleepUntilWallclock<'_, Self>
fn sleep_until_wallclock(
&self,
when: SystemTime
) -> SleepUntilWallclock<'_, Self>
Pause until the wall-clock is at when
or later, trying to
recover from clock jumps. Read more
sourceimpl<Sp> SpawnExt for Sp where
Sp: Spawn + ?Sized,
impl<Sp> SpawnExt for Sp where
Sp: Spawn + ?Sized,
sourcefn spawn<Fut>(&self, future: Fut) -> Result<(), SpawnError> where
Fut: 'static + Future<Output = ()> + Send,
fn spawn<Fut>(&self, future: Fut) -> Result<(), SpawnError> where
Fut: 'static + Future<Output = ()> + Send,
Spawns a task that polls the given future with output ()
to
completion. Read more
sourcefn spawn_with_handle<Fut>(
&self,
future: Fut
) -> Result<RemoteHandle<<Fut as Future>::Output>, SpawnError> where
Fut: 'static + Future + Send,
<Fut as Future>::Output: Send,
fn spawn_with_handle<Fut>(
&self,
future: Fut
) -> Result<RemoteHandle<<Fut as Future>::Output>, SpawnError> where
Fut: 'static + Future + Send,
<Fut as Future>::Output: Send,
Spawns a task that polls the given future to completion and returns a future that resolves to the spawned future’s output. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more