pub struct Interchange<Rq, Rp, const N: usize> { /* private fields */ }
Expand description

Set of N channels

Channels can be claimed with claim()

static interchange: Interchange<Request, Response,10> = Interchange::new();

for i in 0..10 {
    let rq: Requester<'_, Request, Response>;
    let rp: Responder<'_, Request, Response>;
    (rq, rp) = interchange.claim().unwrap() ;
}

Implementations§

source§

impl<Rq, Rp, const N: usize> Interchange<Rq, Rp, N>

source

pub const fn new() -> Self

Create a new Interchange

source

pub fn claim(&self) -> Option<(Requester<'_, Rq, Rp>, Responder<'_, Rq, Rp>)>

Claim one of the channels of the interchange. Returns None if called more than N times.

source

pub const fn as_interchange_ref(&self) -> InterchangeRef<'_, Rq, Rp>

Returns a reference to the interchange with the N const-generic removed. This can avoid the requirement to have const N: usize everywhere

static INTERCHANGE_INNER: Interchange<Request, Response, 1> = Interchange::new();

// The size of the interchange is absent from the type
static INTERCHANGE: InterchangeRef<'static, Request, Response> = INTERCHANGE_INNER.as_interchange_ref();

let (mut rq, mut rp) = INTERCHANGE.claim().unwrap();

Trait Implementations§

source§

impl<Rq, Rp, const N: usize> Default for Interchange<Rq, Rp, N>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Rq, Rp, const N: usize> !RefUnwindSafe for Interchange<Rq, Rp, N>

§

impl<Rq, Rp, const N: usize> Send for Interchange<Rq, Rp, N>where Rp: Send, Rq: Send,

§

impl<Rq, Rp, const N: usize> Sync for Interchange<Rq, Rp, N>where Rp: Send + Sync, Rq: Send + Sync,

§

impl<Rq, Rp, const N: usize> Unpin for Interchange<Rq, Rp, N>where Rp: Unpin, Rq: Unpin,

§

impl<Rq, Rp, const N: usize> UnwindSafe for Interchange<Rq, Rp, N>where Rp: UnwindSafe, Rq: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.