Struct dialectic::Branches[][src]

#[must_use]pub struct Branches<Choices, Tx, Rx> where
    Tx: Send + 'static,
    Rx: Send + 'static,
    Choices: Tuple + 'static,
    Choices::AsList: EachScoped + EachHasDual + HasLength
{ /* fields omitted */ }

The result of offer: an N-ary enumeration of the possible Chans that could result from the what the other party chooses.

To find out which protocol was selected by the other party, use Branches::case (the analogue to a match statement on Branches).

💡 When possible, prefer the offer! macro over using Branches and case. It guarantees exhaustiveness, and is more concise, readable, and asymptotically efficient.

Implementations

impl<Tx, Rx, Choices, const LENGTH: usize> Branches<Choices, Tx, Rx> where
    Choices: Tuple + 'static,
    Choices::AsList: EachScoped + EachHasDual + HasLength,
    <Choices::AsList as HasLength>::Length: ToConstant<AsConstant = Number<LENGTH>>,
    Tx: Send + 'static,
    Rx: Send + 'static, 
[src]

pub fn case<const N: usize>(
    self
) -> Result<Chan<<Choices::AsList as Select<<Number<N> as ToUnary>::AsUnary>>::Selected, Tx, Rx>, Branches<<<Choices::AsList as Select<<Number<N> as ToUnary>::AsUnary>>::Remainder as List>::AsTuple, Tx, Rx>> where
    Number<N>: ToUnary,
    Choices::AsList: Select<<Number<N> as ToUnary>::AsUnary>,
    <Choices::AsList as Select<<Number<N> as ToUnary>::AsUnary>>::Selected: Session,
    <Choices::AsList as Select<<Number<N> as ToUnary>::AsUnary>>::Remainder: EachScoped + EachHasDual + HasLength + List
[src]

Check if the selected protocol in this Branches was the Nth protocol in its type. If so, return the corresponding channel; otherwise, return all the other possibilities.

pub fn choice(&self) -> Choice<LENGTH>[src]

Determine the Choice which was made by the other party, indicating which of these Branches should be taken.

Ordinarily, you should prefer the offer! macro in situations where you need to know this value.

impl<'a, Tx, Rx> Branches<(), Tx, Rx> where
    Tx: Send + 'static,
    Rx: Send + 'static, 
[src]

pub fn empty_case<T>(self) -> T[src]

Eliminate an empty Branches, returning any type. Any code in which this function can be called is unreachable, because it’s impossible to construct an empty Branches.

Trait Implementations

impl<Choices, Tx, Rx> Debug for Branches<Choices, Tx, Rx> where
    Tx: Send + 'static,
    Rx: Send + 'static,
    Choices: Tuple + 'static,
    Choices::AsList: EachScoped + EachHasDual + HasLength,
    Tx: Debug,
    Rx: Debug
[src]

impl<Tx, Rx, Choices> Drop for Branches<Choices, Tx, Rx> where
    Tx: Send + 'static,
    Rx: Send + 'static,
    Choices: Tuple + 'static,
    Choices::AsList: EachScoped + EachHasDual + HasLength
[src]

Auto Trait Implementations

impl<Choices, Tx, Rx> RefUnwindSafe for Branches<Choices, Tx, Rx> where
    Rx: RefUnwindSafe,
    Tx: RefUnwindSafe

impl<Choices, Tx, Rx> Send for Branches<Choices, Tx, Rx>

impl<Choices, Tx, Rx> Sync for Branches<Choices, Tx, Rx> where
    Rx: Sync,
    Tx: Sync

impl<Choices, Tx, Rx> Unpin for Branches<Choices, Tx, Rx> where
    Rx: Unpin,
    Tx: Unpin

impl<Choices, Tx, Rx> UnwindSafe for Branches<Choices, Tx, Rx> where
    Rx: UnwindSafe,
    Tx: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<'a, T, S> As<'a, Val, T> for S where
    S: Into<T>, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> By<'a, Mut> for T where
    T: 'a, 
[src]

type Type = &'a mut T

The type of Self when called by Convention.

impl<'a, T> By<'a, Ref> for T where
    T: 'a, 
[src]

type Type = &'a T

The type of Self when called by Convention.

impl<'a, T> By<'a, Val> for T[src]

type Type = T

The type of Self when called by Convention.

impl<'a, T> Convert<'a, Mut, Mut> for T where
    T: 'a, 
[src]

impl<'a, T> Convert<'a, Mut, Ref> for T where
    T: 'a, 
[src]

impl<'a, T> Convert<'a, Ref, Ref> for T where
    T: 'a, 
[src]

impl<'a, T> Convert<'a, Val, Val> for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.