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

Close a channel. Should always be used at the end of your program.

Close the channel and return an error due to some business logic violation.

Send a value of type T over the channel. Returns a channel with protocol P.

Receives a value of type T from the channel. Returns a tuple containing the resulting channel and the received value.

Perform an active choice, selecting protocol P. We haven’t sent any value yet, so the agency stays on our side.

Perform an active choice, selecting protocol Q. We haven’t sent any value yet, so the agency stays on our side.

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.

Enter a recursive environment, putting the current environment on the top of the environment stack.

Recurse to the environment on the top of the environment stack. The agency must be kept, since there’s no message exchange here, we just start from the top as a continuation of where we are.

Pop the top environment from the environment stack.

Trait Implementations

A sanity check destructor that kicks in if we abandon the channel by returning Ok(_) without closing it first.

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.