Send Value

Provider Rule: Send Value

fn send_value<T, C, A>(
  val: T,
  cont: PartialSession<C, A>,
) ->
  PartialSession<C, SendValue<T, A>>

Example

    let p: Session<SendValue<String, End>> =
      send_value("Hello World!".to_string(), terminate());

Client Rule: Receive Value From

fn receive_value_from<N, C1, C2, T, A, B>(
  n: N,
  cont: impl FnOnce(T) -> PartialSession<C2, B>,
) -> PartialSession<C1, B>
  • C1 is in the form HList[…, N: SendValue<T, A>, …].
  • C2 is in the form HList[…, N: A, …], with the remaining elements being the same as C1.

Example

    let p: Session<ReceiveChannel<SendValue<String, End>, End>> =
      receive_channel(move |c| {
        receive_value_from(c, move |name| {
          println!("Hello, {}!", name);
          wait(c, terminate())
        })
      });