duper_rpc

Crates.ioduper_rpc
lib.rsduper_rpc
version0.1.0
created_at2026-01-03 17:01:29.377908+00
updated_at2026-01-03 17:01:29.377908+00
descriptionAn RPC implementation for Duper.
homepagehttps://duper.dev.br
repositoryhttps://github.com/EpicEric/duper
max_upload_size
id2020473
size199,845
Eric Rodrigues Pires (EpicEric)

documentation

README

The Duper logo, with a confident spectacled mole wearing a flailing blue cape.

duper_rpc

crates.io version GitHub license

An RPC implementation for Duper.

Check out the specification for Duper RPC.

Example with Axum

cargo add axum_duper duper_rpc
use axum::{extract::State, Router, routing::post};
use axum_duper::Duper;
use duper::DuperValue;
use duper_rpc::server::{IntoService, ServerPart};
use serde::{Deserialize, Serialize};

#[derive(Deserialize)]
struct Params {
    text: String,
}

#[derive(Clone)]
struct AppState(u64);

async fn handle_only_state(duper_rpc::State(state): duper_rpc::State<AppState>) -> duper_rpc::Result<u64> {
    Ok(state.0)
}

async fn handle_params(params: Params, flag: bool) -> duper_rpc::Result<String> {
    if flag {
        Ok(params.text)
    } else {
        Err(duper_rpc::Error::Custom(DuperValue::String {
            identifier: None,
            inner: "Flag is false".into()
        }))
    }
}

async fn rpc_handler(State(state): State<AppState>, request: Duper(duper_rpc::Request)) -> impl IntoResponse {
    let Ok(response) = duper_rpc::Server::new()
        .method("foo", handle_only_state)
        .method("bar", handle_params)
        .method("healthy", async || Ok(true))
        .with_state(state)
        .handle(request)
        .await;
    match response {
        Some(response) => Duper(response).into_response(),
        None => StatusCode::NO_CONTENT.into_response(),
    }
}

let app = Router::new().route("/rpc", post(rpc_handler)).with_state(AppState(42));
Commit count: 0

cargo fmt