Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ranile/ripsy
RPC between Server/Client written in Rust
https://github.com/ranile/ripsy
rpc rust
Last synced: about 1 month ago
JSON representation
RPC between Server/Client written in Rust
- Host: GitHub
- URL: https://github.com/ranile/ripsy
- Owner: ranile
- License: apache-2.0
- Created: 2023-09-07T22:38:58.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2023-09-07T23:09:30.000Z (about 1 year ago)
- Last Synced: 2024-09-17T15:57:59.829Z (about 2 months ago)
- Topics: rpc, rust
- Language: Rust
- Homepage: https://crates.io/crates/ripsy
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
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**
```rust
use shared::add;#[tokio::main]
async fn main() {
ripsy::client::init("http://localhost:3000");
let r: Result = add(2).await.unwrap();
println!("{r:?}"); // Ok("2")
}
```**server/main.rs**
```rust
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**
```rust
use ripsy::endpoint;#[endpoint(mutation)]
pub async fn add(n: u32) -> Result {
if false {
work()?; // ? works fine
}
Ok(n.to_string())
}fn work() -> Result<(), String> { Err("err".to_string()) }
```