From 4083a07c380f3d9f7e9909b26fcd3601aecd18d7 Mon Sep 17 00:00:00 2001 From: Shun Kashiwa Date: Wed, 16 Oct 2024 17:11:48 -0700 Subject: [PATCH] delete outdated document --- chorus_book/src/guide-enclave.md | 64 +------------------------------- 1 file changed, 1 insertion(+), 63 deletions(-) diff --git a/chorus_book/src/guide-enclave.md b/chorus_book/src/guide-enclave.md index 2ff895c..f14f9b7 100644 --- a/chorus_book/src/guide-enclave.md +++ b/chorus_book/src/guide-enclave.md @@ -112,66 +112,4 @@ impl Choreography for MainChoreography { } ``` -## Returning Values from Enclave - -Just like the `call` operator, the `enclave` operator can return a value. However, the type of the returned value must implement the `Superposition` trait. `Superposition` provides a way for ChoRus to construct a value on locations that are not specified in the `enclave` operator. - -In general, `Superposition` is either a located value or a struct consisting only of located values. The `Located` struct implements the `Superposition` trait, so you can return located values without any code. If you wish to return a struct of located values, you need to derive the `Superposition` trait using the derive macro. - -```rust -{{#include ./header.txt}} -# fn get_random_number() -> u32 { -# 42 // for presentation purpose -# } -# -#[derive(Superposition)] -struct BobCarolResult { - is_even_at_bob: Located, - is_even_at_carol: Located, -} - -struct BobCarolChoreography { - x_at_bob: Located, -}; - -impl Choreography for BobCarolChoreography { - type L = LocationSet!(Bob, Carol); - fn run(self, op: &impl ChoreoOp) -> BobCarolResult { - let is_even_at_bob: Located = op.locally(Bob, |un| { - let x = un.unwrap(&self.x_at_bob); - x % 2 == 0 - }); - let is_even: bool = op.broadcast(Bob, is_even_at_bob.clone()); - if is_even { - let x_at_carol = op.comm(Bob, Carol, &self.x_at_bob); - op.locally(Carol, |un| { - let x = un.unwrap(&x_at_carol); - println!("x is even: {}", x); - }); - } - BobCarolResult { - is_even_at_bob, - is_even_at_carol: op.locally(Carol, |_| is_even), - } - } -} - -struct MainChoreography; - -impl Choreography for MainChoreography { - type L = LocationSet!(Alice, Bob, Carol); - fn run(self, op: &impl ChoreoOp) { - let x_at_alice = op.locally(Alice, |_| { - get_random_number() - }); - let x_at_bob = op.comm(Alice, Bob, &x_at_alice); - let BobCarolResult { - is_even_at_bob, - is_even_at_carol, - } = op.enclave(BobCarolChoreography { - x_at_bob, - }); - // can access is_even_at_bob and is_even_at_carol using `locally` on Bob and Carol - } -} -``` +