pub struct Chan<P, E, R> { /* private fields */ }
Expand description
A session typed channel. P
is the protocol and E
is the environment,
containing potential recursion targets. R
is the representation of
messages, which could be DynMessage
, or perhaps something we know
statically how to turn into JSON or bytes.
Implementations§
Source§impl<E, R> Chan<Eps, E, R>
impl<E, R> Chan<Eps, E, R>
Sourcepub fn close(self) -> SessionResult<()>
pub fn close(self) -> SessionResult<()>
Close a channel. Should always be used at the end of your program.
Source§impl<P, E, T, R: Repr<T>> Chan<Send<T, P>, E, R>
impl<P, E, T, R: Repr<T>> Chan<Send<T, P>, E, R>
Sourcepub fn send(self, v: T) -> SessionResult<Chan<P, E, R>>
pub fn send(self, v: T) -> SessionResult<Chan<P, E, R>>
Send a value of type T
over the channel. Returns a channel with protocol P
.
Source§impl<P, E, T, R: Repr<T>> Chan<Recv<T, P>, E, R>
impl<P, E, T, R: Repr<T>> Chan<Recv<T, P>, E, R>
Sourcepub async fn recv(self, timeout: Duration) -> SessionResult<(Chan<P, E, R>, T)>
pub async fn recv(self, timeout: Duration) -> SessionResult<(Chan<P, E, R>, T)>
Receives a value of type T
from the channel. Returns a tuple
containing the resulting channel and the received value.
Source§impl<P: Outgoing, Q: Outgoing, E, R> Chan<Choose<P, Q>, E, R>
impl<P: Outgoing, Q: Outgoing, E, R> Chan<Choose<P, Q>, E, R>
Source§impl<P: Incoming, Q: Incoming, E, R> Chan<Offer<P, Q>, E, R>
impl<P: Incoming, Q: Incoming, E, R> Chan<Offer<P, Q>, E, R>
Sourcepub async fn offer(
self,
t: Duration,
) -> SessionResult<Branch<Chan<P, E, R>, Chan<Q, E, R>>>
pub async fn offer( self, t: Duration, ) -> SessionResult<Branch<Chan<P, E, R>, Chan<Q, E, R>>>
Passive choice. This allows the other end of the channel to select one
of two options for continuing the protocol: either P
or Q
.
Both options mean they will have to send a message to us,
the agency is on their side.
Trait Implementations§
Auto Trait Implementations§
impl<P, E, R> Freeze for Chan<P, E, R>where
R: Freeze,
impl<P, E, R> RefUnwindSafe for Chan<P, E, R>
impl<P, E, R> Send for Chan<P, E, R>
impl<P, E, R> Sync for Chan<P, E, R>
impl<P, E, R> Unpin for Chan<P, E, R>
impl<P, E, R> UnwindSafe for Chan<P, E, R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more