Struct dialectic::Branches [−][src]
The result of offer
: an N
-ary enumeration of the possible Chan
s that
could result from the what the other party choose
s.
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]
Choices: Tuple + 'static,
Choices::AsList: EachScoped + EachHasDual + HasLength,
<Choices::AsList as HasLength>::Length: ToConstant<AsConstant = Number<LENGTH>>,
Tx: Send + 'static,
Rx: Send + 'static,
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]
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,
Check if the selected protocol in this Branches
was the N
th protocol in its type. If
so, return the corresponding channel; otherwise, return all the other possibilities.
pub fn choice(&self) -> Choice<LENGTH>
[src]
impl<'a, Tx, Rx> Branches<(), Tx, Rx> where
Tx: Send + 'static,
Rx: Send + 'static,
[src]
Tx: Send + 'static,
Rx: Send + 'static,
pub fn empty_case<T>(self) -> T
[src]
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]
Tx: Send + 'static,
Rx: Send + 'static,
Choices: Tuple + 'static,
Choices::AsList: EachScoped + EachHasDual + HasLength,
Tx: Debug,
Rx: Debug,
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]
Tx: Send + 'static,
Rx: Send + 'static,
Choices: Tuple + 'static,
Choices::AsList: EachScoped + EachHasDual + HasLength,
Auto Trait Implementations
impl<Choices, Tx, Rx> RefUnwindSafe for Branches<Choices, Tx, Rx> where
Rx: RefUnwindSafe,
Tx: RefUnwindSafe,
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,
Rx: Sync,
Tx: Sync,
impl<Choices, Tx, Rx> Unpin for Branches<Choices, Tx, Rx> where
Rx: Unpin,
Tx: Unpin,
Rx: Unpin,
Tx: Unpin,
impl<Choices, Tx, Rx> UnwindSafe for Branches<Choices, Tx, Rx> where
Rx: UnwindSafe,
Tx: UnwindSafe,
Rx: UnwindSafe,
Tx: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<'a, T, S> As<'a, Val, T> for S where
S: Into<T>,
[src]
S: Into<T>,
pub fn as_convention(this: S) -> T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<'a, T> By<'a, Mut> for T where
T: 'a,
[src]
T: 'a,
impl<'a, T> By<'a, Ref> for T where
T: 'a,
[src]
T: 'a,
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]
T: 'a,
impl<'a, T> Convert<'a, Mut, Ref> for T where
T: 'a,
[src]
T: 'a,
impl<'a, T> Convert<'a, Ref, Ref> for T where
T: 'a,
[src]
T: 'a,
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]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,