async fn fib_child_task(ctx: BastionContext) -> Result<(), ()> {
    loop {
        // This macro is weird.
        // Bear with me as I tell you more
        // about the variants in the match statements below.
        // so the first line means "wait for the next message", and then lets match against it
        msg! { ctx.recv().await?,
            // =!> refer to messages that can be replied to.
            // In order to reply to a message, we use the answer! macro
            // and pass ctx as parameter, so that bastion knows where to send the reply
            request: String =!> {
                let (command, number) = deserialize_into_fib_command(request);
                if command == "fib" {
                    answer!(ctx, format!("{}", fib(number))).expect("couldn't reply :(");
                } else {
                    answer!(ctx, "I'm sorry I didn't understand the task I was supposed to do").expect("couldn't reply :(");
                }
            };
            // ref <name> are broadcasts.
            // each child in a children group receives a broadcast and can process it.
            ref broadcast: String => {
                info!("received broadcast: {:?}", *broadcast);
            };
            // <name> (without the ref keyword) are messages that have a unique recipient.
            message: String => {
                info!("someone told me something: {}", message);
            };
            // <name> that have the `_` type are catch alls
            unknown:_ => {
                error!("uh oh, I received a message I didn't understand\n {:?}", unknown);
            };
        }
    }
}
// This is the heavylifting.
// A child will wait for a message, and try to process it.
This is the heavylifting.
A child will wait for a message, and try to process it.
This is the heavylifting . A child will wait for a message and try to process it .
async fn fib_child_task(ctx: BastionContext) -> Result<(), ()> {
    loop {
        // This macro is weird.
        // Bear with me as I tell you more
        // about the variants in the match statements below.
        // so the first line means "wait for the next message", and then lets match against it
        msg! { ctx.recv().await?,
            // =!> refer to messages that can be replied to.
            // In order to reply to a message, we use the answer! macro
            // and pass ctx as parameter, so that bastion knows where to send the reply
            request: String =!> {
                let (command, number) = deserialize_into_fib_command(request);
                if command == "fib" {
                    answer!(ctx, format!("{}", fib(number))).expect("couldn't reply :(");
                } else {
                    answer!(ctx, "I'm sorry I didn't understand the task I was supposed to do").expect("couldn't reply :(");
                }
            };
            // ref <name> are broadcasts.
            // each child in a children group receives a broadcast and can process it.
            ref broadcast: String => {
                info!("received broadcast: {:?}", *broadcast);
            };
            // <name> (without the ref keyword) are messages that have a unique recipient.
            message: String => {
                info!("someone told me something: {}", message);
            };
            // <name> that have the `_` type are catch alls
            unknown:_ => {
                error!("uh oh, I received a message I didn't understand\n {:?}", unknown);
            };
        }
    }
}
async fn fib_child_task ( ctx : BastionContext ) -> Result < ( ) , ( ) > { loop { // This macro is weird. // Bear with me as I tell you more // about the variants in the match statements below. // so the first line means "wait for the next message", and then lets match against it msg ! { ctx recv ( ) await // =!> refer to messages that can be replied to. // In order to reply to a message, we use the answer! macro // and pass ctx as parameter, so that bastion knows where to send the reply request String { let ( command number ) deserialize_into_fib_command ( request ) if command " " { answer ( ctx format ( " " fib ( number ) ) ) expect ( " " ) } else { answer ( ctx " " ) expect ( " " ) } } // ref <name> are broadcasts. // each child in a children group receives a broadcast and can process it. ref broadcast String { info ( " " broadcast ) } // <name> (without the ref keyword) are messages that have a unique recipient. message String { info ( " " message ) } // <name> that have the `_` type are catch alls unknown { error ( " \n " unknown ) } } } }
This is the heavylifting.
This is the heavylifting .
ctx
BastionContext
ctx
BastionContext