Struct tor_rtmock::net::MockNetProvider[][src]

pub struct MockNetProvider { /* fields omitted */ }
Expand description

A view of a single host’s access to a MockNetwork.

Each simulated host has its own addresses that it’s allowed to listen on, and a reference to the network.

This type implements TcpProvider so that it can be used as a drop-in replacement for testing code that uses the network.

Limitations

There’s no randomness here, so we can’t simulate the weirdness of real networks.

So far, there’s no support for DNS or UDP.

We don’t handle localhost specially, and we don’t simulate providers that can connect to some addresses but not all.

We don’t do the right thing (block) if there is a listener that never calls accept.

We use a simple u16 counter to decide what arbitrary port numbers to use: Once that counter is exhausted, we will fail with an assertion. We don’t do anything to prevent those arbitrary ports from colliding with specified ports, other than declare that you can’t have two listeners on the same addr:port at the same time.

We pretend to provide TLS, but there’s no actual encryption or authentication.

Implementations

Create a mock TLS listener with provided certificate.

Note that no encryption or authentication is actually performed! Other parties are simply told that their connections succeeded and were authenticated against the given certificate.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. 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.

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

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more