Struct mpstthree::meshedchannels::MeshedChannels

source ·
pub struct MeshedChannels<S1, S2, R, N>
where S1: Session, S2: Session, R: Role, N: Name,
{ /* private fields */ }
Expand description

The structure which encapsulates two binary session types, a stack and a name.

§Arguments

  • The first binary session. It must be filled with Send and/or Recv and end with End.

  • The second binary session. It must be filled with Send and/or Recv and end with End.

  • The stack of the MeshedChannels. It must be filled with a role, such as RoleA or RoleBtoAll and end with RoleEnd.

  • The name of the role of the MeshedChannels. It must be one among: RoleA, RoleB or RoleC.

§Example

use mpstthree::binary::struct_trait::{end::End, recv::Recv, send::Send, session::Session};

use mpstthree::meshedchannels::MeshedChannels;

use mpstthree::role::b::RoleB;
use mpstthree::role::c::RoleC;
use mpstthree::role::end::RoleEnd;

use mpstthree::name::a::NameA;

// Creating the binary sessions
type AtoB<N> = Send<N, End>;
type AtoC<N> = Recv<N, End>;

// Stacks
type StackA = RoleB<RoleC<RoleEnd>>;

// Creating the MP sessions
type EndpointA<N> = MeshedChannels<AtoB<N>, AtoC<N>, StackA, NameA>;

let _ = EndpointA::<i32>::new(); // Only used for example

Implementations§

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<Send<T, S1>, S2, RoleB<R>, NameA>

source

pub fn send(self, payload: T) -> MeshedChannels<S1, S2, R, NameA>

Send a payload of type T to role B

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<S1, Send<T, S2>, RoleC<R>, NameA>

source

pub fn send(self, payload: T) -> MeshedChannels<S1, S2, R, NameA>

Send a payload of type T to role C

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<Recv<T, S1>, S2, RoleB<R>, NameA>

source

pub fn recv( self ) -> Result<(T, MeshedChannels<S1, S2, R, NameA>), Box<dyn Error>>

Receive a payload from role B

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<S1, Recv<T, S2>, RoleC<R>, NameA>

source

pub fn recv( self ) -> Result<(T, MeshedChannels<S1, S2, R, NameA>), Box<dyn Error>>

Receive a payload from role C

source§

impl<'a, S1: Session, S2: Session, S3: Session, S4: Session, R1: Role, R2: Role> MeshedChannels<OfferMpst<S1, S2, S3, S4, R1, R2, NameA>, End, RoleAlltoB<RoleEnd, RoleEnd>, NameA>

source

pub fn offer<F, G, U>(self, f: F, g: G) -> Result<U, Box<dyn Error + 'a>>
where F: FnOnce(MeshedChannels<S1, S2, R1, NameA>) -> Result<U, Box<dyn Error + 'a>>, G: FnOnce(MeshedChannels<S3, S4, R2, NameA>) -> Result<U, Box<dyn Error + 'a>>,

Receive a binary choice from role B. Be careful: the left and right stacks must be the same.

source§

impl<'a, S1: Session, S2: Session, S3: Session, S4: Session, R1: Role, R2: Role> MeshedChannels<End, OfferMpst<S1, S2, S3, S4, R1, R2, NameA>, RoleAlltoC<RoleEnd, RoleEnd>, NameA>

source

pub fn offer<F, G, U>(self, f: F, g: G) -> Result<U, Box<dyn Error + 'a>>
where F: FnOnce(MeshedChannels<S1, S2, R1, NameA>) -> Result<U, Box<dyn Error + 'a>>, G: FnOnce(MeshedChannels<S3, S4, R2, NameA>) -> Result<U, Box<dyn Error + 'a>>,

Receive a binary choice from role C. Be careful: the left and right stacks must be the same.

source§

impl<S0: Session, S1: Session, S2: Session, S3: Session, S4: Session, S5: Session, R0: Role, R1: Role, R2: Role, R3: Role, R4: Role, R5: Role> MeshedChannels<Send<Either<MeshedChannels<S2, <S0 as Session>::Dual, R0, NameB>, MeshedChannels<S4, <S1 as Session>::Dual, R1, NameB>>, End>, Send<Either<MeshedChannels<S3, S0, R2, NameC>, MeshedChannels<S5, S1, R3, NameC>>, End>, RoleAtoAll<R4, R5>, NameA>

source

pub fn choose_left( self ) -> MeshedChannels<<S2 as Session>::Dual, <S3 as Session>::Dual, R4, NameA>

Choose the left branch of a binary choice and send it to B and C

source

pub fn choose_right( self ) -> MeshedChannels<<S4 as Session>::Dual, <S5 as Session>::Dual, R5, NameA>

Choose the right branch of a binary choice and send it to B and C

source§

impl MeshedChannels<End, End, RoleEnd, NameA>

source

pub fn close(self) -> Result<(), Box<dyn Error>>

Close the current connection

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<Send<T, S1>, S2, RoleA<R>, NameB>

source

pub fn send(self, payload: T) -> MeshedChannels<S1, S2, R, NameB>

Send a payload of type T to role A

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<S1, Send<T, S2>, RoleC<R>, NameB>

source

pub fn send(self, payload: T) -> MeshedChannels<S1, S2, R, NameB>

Send a payload of type T to role C

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<Recv<T, S1>, S2, RoleA<R>, NameB>

source

pub fn recv( self ) -> Result<(T, MeshedChannels<S1, S2, R, NameB>), Box<dyn Error>>

Receive a payload from role A

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<S1, Recv<T, S2>, RoleC<R>, NameB>

source

pub fn recv( self ) -> Result<(T, MeshedChannels<S1, S2, R, NameB>), Box<dyn Error>>

Receive a payload from role C

source§

impl<'a, S1: Session, S2: Session, S3: Session, S4: Session, R1: Role, R2: Role> MeshedChannels<OfferMpst<S1, S2, S3, S4, R1, R2, NameB>, End, RoleAlltoA<RoleEnd, RoleEnd>, NameB>

source

pub fn offer<F, G, U>(self, f: F, g: G) -> Result<U, Box<dyn Error + 'a>>
where F: FnOnce(MeshedChannels<S1, S2, R1, NameB>) -> Result<U, Box<dyn Error + 'a>>, G: FnOnce(MeshedChannels<S3, S4, R2, NameB>) -> Result<U, Box<dyn Error + 'a>>,

Receive a binary choice from role A. Be careful: the left and right stacks must be the same.

source§

impl<'a, S1: Session, S2: Session, S3: Session, S4: Session, R1: Role, R2: Role> MeshedChannels<End, OfferMpst<S1, S2, S3, S4, R1, R2, NameB>, RoleAlltoC<RoleEnd, RoleEnd>, NameB>

source

pub fn offer<F, G, U>(self, f: F, g: G) -> Result<U, Box<dyn Error + 'a>>
where F: FnOnce(MeshedChannels<S1, S2, R1, NameB>) -> Result<U, Box<dyn Error + 'a>>, G: FnOnce(MeshedChannels<S3, S4, R2, NameB>) -> Result<U, Box<dyn Error + 'a>>,

Receive a binary choice from role C. Be careful: the left and right stacks must be the same.

source§

impl<S0: Session, S1: Session, S2: Session, S3: Session, S4: Session, S5: Session, R0: Role, R1: Role, R2: Role, R3: Role, R4: Role, R5: Role> MeshedChannels<Send<Either<MeshedChannels<S2, <S0 as Session>::Dual, R0, NameA>, MeshedChannels<S4, <S1 as Session>::Dual, R1, NameA>>, End>, Send<Either<MeshedChannels<S0, S3, R2, NameC>, MeshedChannels<S1, S5, R3, NameC>>, End>, RoleBtoAll<R4, R5>, NameB>

source

pub fn choose_left( self ) -> MeshedChannels<<S2 as Session>::Dual, <S3 as Session>::Dual, R4, NameB>

Choose the right branch of a binary choice and send it to A and C

source

pub fn choose_right( self ) -> MeshedChannels<<S4 as Session>::Dual, <S5 as Session>::Dual, R5, NameB>

Choose the left branch of a binary choice and send it to A and C

source§

impl MeshedChannels<End, End, RoleEnd, NameB>

source

pub fn close(self) -> Result<(), Box<dyn Error>>

Close the current connection

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<Send<T, S1>, S2, RoleA<R>, NameC>

source

pub fn send(self, payload: T) -> MeshedChannels<S1, S2, R, NameC>

Send a payload of type T to role A

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<S1, Send<T, S2>, RoleB<R>, NameC>

source

pub fn send(self, payload: T) -> MeshedChannels<S1, S2, R, NameC>

Send a payload of type T to role B

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<Recv<T, S1>, S2, RoleA<R>, NameC>

source

pub fn recv( self ) -> Result<(T, MeshedChannels<S1, S2, R, NameC>), Box<dyn Error>>

Receive a payload from role A

source§

impl<S1: Session, S2: Session, R: Role, T: Send> MeshedChannels<S1, Recv<T, S2>, RoleB<R>, NameC>

source

pub fn recv( self ) -> Result<(T, MeshedChannels<S1, S2, R, NameC>), Box<dyn Error>>

Receive a payload from role B

source§

impl<'a, S1: Session, S2: Session, S3: Session, S4: Session, R1: Role, R2: Role> MeshedChannels<OfferMpst<S1, S2, S3, S4, R1, R2, NameC>, End, RoleAlltoA<RoleEnd, RoleEnd>, NameC>

source

pub fn offer<F, G, U>(self, f: F, g: G) -> Result<U, Box<dyn Error + 'a>>
where F: FnOnce(MeshedChannels<S1, S2, R1, NameC>) -> Result<U, Box<dyn Error + 'a>>, G: FnOnce(MeshedChannels<S3, S4, R2, NameC>) -> Result<U, Box<dyn Error + 'a>>,

Receive a binary choice from role A. Be careful: the left and right stacks must be the same.

source§

impl<'a, S1: Session, S2: Session, S3: Session, S4: Session, R1: Role, R2: Role> MeshedChannels<End, OfferMpst<S1, S2, S3, S4, R1, R2, NameC>, RoleAlltoB<RoleEnd, RoleEnd>, NameC>

source

pub fn offer<F, G, U>(self, f: F, g: G) -> Result<U, Box<dyn Error + 'a>>
where F: FnOnce(MeshedChannels<S1, S2, R1, NameC>) -> Result<U, Box<dyn Error + 'a>>, G: FnOnce(MeshedChannels<S3, S4, R2, NameC>) -> Result<U, Box<dyn Error + 'a>>,

Receive a binary choice from role B. Be careful: the left and right stacks must be the same.

source§

impl<S0: Session, S1: Session, S2: Session, S3: Session, S4: Session, S5: Session, R0: Role, R1: Role, R2: Role, R3: Role, R4: Role, R5: Role> MeshedChannels<Send<Either<MeshedChannels<<S0 as Session>::Dual, S2, R0, NameA>, MeshedChannels<<S1 as Session>::Dual, S4, R1, NameA>>, End>, Send<Either<MeshedChannels<S0, S3, R2, NameB>, MeshedChannels<S1, S5, R3, NameB>>, End>, RoleCtoAll<R4, R5>, NameC>

source

pub fn choose_left( self ) -> MeshedChannels<<S2 as Session>::Dual, <S3 as Session>::Dual, R4, NameC>

Choose the left branch of a binary choice and send it to A and B

source

pub fn choose_right( self ) -> MeshedChannels<<S4 as Session>::Dual, <S5 as Session>::Dual, R5, NameC>

Choose the right branch of a binary choice and send it to A and B

source§

impl MeshedChannels<End, End, RoleEnd, NameC>

source

pub fn close(self) -> Result<(), Box<dyn Error>>

Close the current connection

source§

impl<S1: Session, S2: Session, R: Role, N: Name> MeshedChannels<S1, S2, R, N>

source

pub fn cancel(self)

Cancel the session

Trait Implementations§

source§

impl<S1, S2, R, N> Debug for MeshedChannels<S1, S2, R, N>
where S1: Session + Debug, S2: Session + Debug, R: Role + Debug, N: Name + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S1: Session, S2: Session, R: Role, N: Name> Session for MeshedChannels<S1, S2, R, N>

§

type Dual = MeshedChannels<<S1 as Session>::Dual, <S2 as Session>::Dual, <R as Role>::Dual, N>

The session type dual to Self.

Auto Trait Implementations§

§

impl<S1, S2, R, N> Freeze for MeshedChannels<S1, S2, R, N>
where S1: Freeze, S2: Freeze, R: Freeze, N: Freeze,

§

impl<S1, S2, R, N> RefUnwindSafe for MeshedChannels<S1, S2, R, N>

§

impl<S1, S2, R, N> Send for MeshedChannels<S1, S2, R, N>

§

impl<S1, S2, R, N> Sync for MeshedChannels<S1, S2, R, N>
where S1: Sync, S2: Sync, R: Sync, N: Sync,

§

impl<S1, S2, R, N> Unpin for MeshedChannels<S1, S2, R, N>
where S1: Unpin, S2: Unpin, R: Unpin, N: Unpin,

§

impl<S1, S2, R, N> UnwindSafe for MeshedChannels<S1, S2, R, N>
where S1: UnwindSafe, S2: UnwindSafe, R: UnwindSafe, N: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V