Skip to main content

ProxyItem

Type Alias ProxyItem 

Source
type ProxyItem<Request, Response, Error> = Arc<Mutex<Option<ResponseSender<Request, Response, Error>>>>;
Expand description

An internal type representing the item that’s sent in the [broadcast] channel.

The actual type that matters is the ResponseSender but since there could be more than one MockService verifying requests, the type must be wrapped so that it can be shared by all receivers:

  • The Arc makes sure the instance is on the heap, and can be shared properly between threads and dropped when no longer needed.
  • The [Mutex] ensures only one MockService instance can reply to the received request.
  • The Option forces the MockService that handles the request to take ownership of it because sending a response also forces the ResponseSender to be dropped.

Aliased Type§

struct ProxyItem<Request, Response, Error> { /* private fields */ }

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 8 bytes