Trait trussed::Interchange
source · [−]pub trait Interchange {
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();
}
Expand description
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
Associated Constants
const CLIENT_CAPACITY: usize
Required methods
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
fn unclaimed_clients() -> usize
Method for debugging: how many allocated clients have not been claimed.
unsafe fn reset_claims()
unsafe fn reset_claims()
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.