A simple macro library for RPC in rust
Go to file
Kodi Craft 7227379e63
All checks were successful
Build library & run tests / build (unix) (push) Successful in 32s
Build library & run tests / build (tcp) (push) Successful in 33s
Try using a matrix to run workflows in parallel
2024-06-22 13:02:54 +02:00
.gitea/workflows Try using a matrix to run workflows in parallel 2024-06-22 13:02:54 +02:00
src Add code to create a client connected to the network 2024-06-22 12:57:41 +02:00
tests Add code to create a client connected to the network 2024-06-22 12:57:41 +02:00
.envrc Move away from devenv.sh 2024-06-21 12:35:45 +02:00
.gitignore Implement basic derivation 2024-06-19 23:25:45 +02:00
.pre-commit-config.yaml Move away from devenv.sh 2024-06-21 12:35:45 +02:00
Cargo.lock Implement basic networking code 2024-06-21 15:54:48 +02:00
Cargo.toml Add code to create a client connected to the network 2024-06-22 12:57:41 +02:00
flake.lock Move away from devenv.sh 2024-06-21 12:35:45 +02:00
flake.nix Fix build options 2024-06-22 13:00:56 +02:00
LICENSE.md Implement basic derivation 2024-06-19 23:25:45 +02:00
README.md Fix typo in README.md 2024-06-21 11:58:24 +02:00

Eagle

Disclaimer

Eagle is still in development and not currently usable. The current state is barely a proof of concept.

What is Eagle?

Eagle is a library designed to make "full-stack" applications with Rust. It allows you to define a communication protocol based on simple "questions" and "answers" which can be implemented as simple functions. From the perspective of the client (which sends "questions") the protocol is simply a set of async functions on a struct. From the perspective of the server (which sends "answers") the protocol is a trait which it implements on any struct of its choice.

Using Eagle

The way that eagle is designed to be used is inside a shared dependency between your "server" and your "client". Both of these should be in a workspace. Create a shared crate which both components should depend on. Inside this crate, you can define your protocol as an enum:

use eagle::Protocol;

#[derive(Protocol)]
pub enum TestProtocol {
    Addition((i32, i32), i32),
    SomeKindOfQuestion(String, i32)
}

In your server, you will be able to implement this protocol for any struct (and in the future register it for communication):

use shared::TestProtocolServer;

pub struct Server;
impl TestProtocolServer for Server {
    fn addition(&mut self, a: i32, b: i32) -> i32 {
        a + b
    }

    fn some_kind_of_question(&mut self, question: String) -> i32 {
        42
    }
}

In your client, you can use an instance of the client struct to query the server:

use shared::TestProtocolClient;

#[tokio::main]
async fn main() {
    let client = TestProtocolClient::new();
    assert_eq!(client.addition(2, 2).await, 4);
}

License

Eagle is licensed under the AGPL (GNU Affero General Public License). To learn more, read LICENSE.md