1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::format;
use ferrite_session::prelude::*;
type HelloSession = ReceiveValue<String, SendValue<String, End>>;
pub fn hello_session() -> Session<End>
{
let server: Session<HelloSession> =
receive_value(|name| send_value(format!("Hello, {}!", name), terminate()));
let client: Session<ReceiveChannel<HelloSession, End>> =
receive_channel(|x| {
send_value_to(
x,
"John".to_string(),
receive_value_from(x, move |result| {
println!("{}", result);
wait(x, terminate())
}),
)
});
apply_channel(client, server)
}
#[tokio::main]
pub async fn main()
{
run_session(hello_session()).await
}