Trait interchange::Interchange[][src]

pub trait Interchange: Sized {
    type REQUEST: Clone;
    type RESPONSE: Clone;

    const CLIENT_CAPACITY: usize;

    fn claim() -> Option<(Requester<Self>, Responder<Self>)>;
fn unclaimed_clients() -> usize;
unsafe fn reset_claims(); }

Do NOT implement this yourself! Use the macro interchange!.

Also, DO NOT use the doc(hidden) methods, if the public API in Requester and Responder are not sufficient for your needs, this means the abstraction is not good enough, and must be fixed here, in interchange.

At compile time, the client capacity is set by using the appropriate call to the interchange! macro. The application can then repeatedly call claim to obtain these clients.

Associated Types

Loading content...

Associated Constants

Loading content...

Required methods

fn claim() -> Option<(Requester<Self>, Responder<Self>)>[src]

This is the constructor for a (Requester, Responder) pair.

Returns singleton static instances until all that were allocated are used up, thereafter, None is returned.

fn unclaimed_clients() -> usize[src]

Method for debugging: how many allocated clients have not been claimed.

unsafe fn reset_claims()[src]

Method purely for testing - do not use in production

Rationale: In production, interchanges are supposed to be set up as global singletons during intialization. In testing however, multiple test cases are run serially; without this reset, such tests would need to allocate an extremely large amount of clients.

It does not work to put this behind a feature flag, as macro expansion happens at call site and can’t see the feature.

Loading content...

Implementors

Loading content...