Looking for feedback

Hi all,

I recently decided to learn rust, and being the kind of person that learns best from practice, I needed to think up a project via which to do this.

TLDR: the code is at GitHub - ralphmorton/bifrost , and I would be interested to hear any feedback on both the code and on the fundamental idea.

To avoid becoming bored, I decided to try build something somewhat novel without any regard for practical usefulness (despite the biblical assurance that there is nothing new under the sun), and what I came up with was a sort of batshit crazy way to do serverless.

The idea is to write applications as monolithic client-side programs, and then via conditional compilation programs are split into client-side and server-side executables. The server-side executable is a WASM (WASI) module which is accessible via a REST API. The client-side executable makes RPC calls to invoke bits of computation that you want to do server-side (for security or whatever).

Despite selecting this project primarily for its batshit-craziness, I am starting to harbour suspicions that something like this could actually be quite useful. Currently, ergonomics are pretty rubbish but that stuff is fairly easy to fix; I am most interested to hear whether anyone thinks this idea could have some practical usefulness.

If anyone has any feedback on the nuts and bolts of the implementation, that would be great too!

Using it ends up looking something like this:

use bifrost::op::Op;
use serde::{Deserialize, Serialize};
#[cfg(feature = "remote")]
use serde::de::DeserializeOwned;

#[derive(Debug, Deserialize, Serialize)]
struct GetEnvVar {
    var: String,
}

impl Op for GetEnvVar {
    type Output = Option<String>;

    fn id() -> &'static str {
        "get_env_var"
    }

    #[cfg(any(feature = "remote", feature = "debug"))]
    fn execute(&self) -> Self::Output {
        std::env::var(&self.var).ok()
    }
}

#[cfg(any(feature = "local", feature = "debug"))]
#[tokio::main]
async fn main() {
    use bifrost::dispatcher::Dispatcher;

    let heimdall_execute_url = String::from("http://localhost:8081/env-example/execute");
    let dispatcher = Dispatcher::create(heimdall_execute_url);

    println!("GetEnvVar:");
    let op = GetEnvVar {
        var: String::from("TEST_VARIABLE"),
    };
    let result = dispatcher.send(&op).await;
    println!("Got result: {:?}", result);
}

#[cfg(feature = "remote")]
bifrost::entrypoint!(GetEnvVar);

Thanks for reading!