pub struct Protocol<P: 'static, S = Bincode, Z: 'static = ()> { /* private fields */ }
Expand description
A Protocol
is a specific type of Process
.
It uses session types to check during compile time that all messages exchanged between two processes are in the correct order and of the correct type.
Only Protocol<End>
or Protocol<TaskEnd>
can be dropped.
All other protocols will panic if dropped without reaching
Protocol<End>
or `Protocol
Implementations§
source§impl<P, S, Z> Protocol<P, S, Z>
impl<P, S, Z> Protocol<P, S, Z>
sourcepub fn from_process<M, S2>(process: Process<M, S2>) -> Self
pub fn from_process<M, S2>(process: Process<M, S2>) -> Self
Turn a process into a protocol.
This implicityly creates a new tag.
sourcepub fn from_process_with_tag<M, S2>(process: Process<M, S2>, tag: Tag) -> Self
pub fn from_process_with_tag<M, S2>(process: Process<M, S2>, tag: Tag) -> Self
Turn a process into a protocol using a given Tag
.
source§impl<P, A, S, Z> Protocol<Send<A, P>, S, Z>where
S: CanSerialize<A>,
impl<P, A, S, Z> Protocol<Send<A, P>, S, Z>where S: CanSerialize<A>,
source§impl<P, A, S, Z> Protocol<Recv<A, P>, S, Z>where
S: CanSerialize<A>,
impl<P, A, S, Z> Protocol<Recv<A, P>, S, Z>where S: CanSerialize<A>,
source§impl<A, S, Z> Protocol<Recv<A, TaskEnd>, S, Z>where
S: CanSerialize<A>,
impl<A, S, Z> Protocol<Recv<A, TaskEnd>, S, Z>where S: CanSerialize<A>,
sourcepub fn result(self) -> A
pub fn result(self) -> A
A task is a special case of a protocol spawned with the spawn!(@task ...)
macro. It only returns one value.
sourcepub fn result_timeout(self, duration: Duration) -> Result<A, MailboxError>
pub fn result_timeout(self, duration: Duration) -> Result<A, MailboxError>
A task is a special case of a protocol spawned with the spawn!(@task ...)
macro. It only returns one value.
source§impl<P, Q, S, Z> Protocol<Choose<P, Q>, S, Z>where
S: CanSerialize<bool>,
impl<P, Q, S, Z> Protocol<Choose<P, Q>, S, Z>where S: CanSerialize<bool>,
sourcepub fn select_left(self) -> Protocol<P, S, Z>
pub fn select_left(self) -> Protocol<P, S, Z>
Perform an active choice, selecting protocol P
.
sourcepub fn select_right(self) -> Protocol<Q, S, Z>
pub fn select_right(self) -> Protocol<Q, S, Z>
Perform an active choice, selecting protocol Q
.