ripsy

Crates.ioripsy
lib.rsripsy
version0.1.0
sourcesrc
created_at2023-09-07 23:05:17.769726
updated_at2023-09-07 23:05:17.769726
descriptionRPC between Server/Client written in Rust
homepage
repositoryhttps://github.com/hamza1311/ripsy
max_upload_size
id966689
size22,207
Elina (ranile)

documentation

https://docs.rs/ripsy

README

Ripsy

RPC between Server/Client written in Rust

Why Ripsy?

RRPC (Rust Remote Procedure Call) is pronounced as ripsy, thus the name of this crate.

Example

client/main.rs

use shared::add;

#[tokio::main]
async fn main() {
    ripsy::client::init("http://localhost:3000");
    let r: Result<String, String> = add(2).await.unwrap();
    println!("{r:?}"); // Ok("2")
}

server/main.rs

use axum::routing::post;
use ripsy::Bincode;
use shared::add;

#[tokio::main]
async fn main() {
    let app = ripsy::ripsy!(add,);

    axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
        .serve(app.into_make_service())
        .await
        .unwrap();
}

shared/lib.rs

use ripsy::endpoint;

#[endpoint(mutation)]
pub async fn add(n: u32) -> Result<String, String> {
    if false {
        work()?; // ? works fine
    }
    Ok(n.to_string())
}

fn work() -> Result<(), String> { Err("err".to_string())  }
Commit count: 4

cargo fmt