pub struct PreferredRuntime { /* private fields */ }
Expand description

The runtime that we prefer to use, out of all the runtimes compiled into the tor-rtcompat crate.

If tokio and async-std are both available, we prefer tokio for its performance. If native_tls and rustls are both available, we prefer native_tls since it has been used in Arti for longer.

Implementations

Obtain a PreferredRuntime from the currently running asynchronous runtime. Generally, this is what you want.

This tries to get a handle to a currently running asynchronous runtime, and wraps it; the returned PreferredRuntime isn’t the same thing as the asynchronous runtime object itself (e.g. tokio::runtime::Runtime).

Panics

When tor-rtcompat is compiled with the tokio feature enabled (regardless of whether the async-std feature is also enabled), panics if called outside of Tokio runtime context. See tokio::runtime::Handle::current.

Usage notes

Once you have a runtime returned by this function, you should just create more handles to it via Clone.

Limitations

If the tor-rtcompat crate was compiled with tokio support, this function will never return a runtime based on async_std.

Create and return a new instance of the default Runtime.

Generally you should call this function at most once, and then use Clone::clone() to create additional references to that runtime.

Tokio users may want to avoid this function and instead obtain a runtime using PreferredRuntime::current: this function always builds a runtime, and if you already have a runtime, that isn’t what you want with Tokio.

If you need more fine-grained control over a runtime, you can create it using an appropriate builder type or function.

Trait Implementations

Run future until it is ready, and return its output.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

A future returned by SleepProvider::sleep()

Return a future that will be ready after duration has elapsed. Read more

Return the SleepProvider’s view of the current instant. Read more

Return the SleepProvider’s view of the current wall-clock time. Read more

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

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

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

Spawns a future that will be run to completion. Read more

Determines whether the executor is able to spawn new tasks. Read more

The type for the TCP connections returned by Self::connect().

The type for the TCP listeners returned by Self::listen().

Launch a TCP connection to a given socket address. Read more

Open a TCP listener on a given socket address.

The Connector object that this provider can return.

The type of the stream returned by that connector.

Return a TLS connector for use with this runtime.

The type of Udp Socket returned by Self::bind()

Bind a local port to send and receive packets from

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Spawns a task that polls the given future with output () to completion. Read more

Spawns a task that polls the given future to completion and returns a future that resolves to the spawned future’s output. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.