Expand description
§rorpc
Unified facade for handler metadata collection, auto-router construction, and TypeScript contract generation.
§Quick Start
ⓘ
use axum::{extract::State, Json};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct Planet { id: i32, name: String }
#[rorpc::get("/planet/list")]
async fn list_planets(State(db): State<Db>) -> Json<Vec<Planet>> {
Json(db.list().await)
}
#[tokio::main]
async fn main() {
let app = rorpc::router!(db);
rorpc::generate_contract()
.output("../client/src/rpc/index.ts")
.unwrap();
axum::serve(listener, app).await.unwrap();
}Re-exports§
pub use codegen::ContractBuilder;pub use error_registry::ErrorRegistration;pub use error_registry::ErrorVariant;pub use metadata::HandlerMetadata;pub use metadata::NamespaceMetadata;pub use registration::HandlerRegistration;pub use schema_registry::EnumRepr;pub use schema_registry::FieldDef;pub use schema_registry::SchemaDef;pub use schema_registry::SchemaRegistration;pub use schema_registry::VariantDef;pub use schema_registry::VariantKind;pub use inventory;
Modules§
- codegen
- TypeScript contract and Zod schema generation.
- error_
registry - Error type registration for TypeScript contract generation.
- metadata
- Handler metadata collected at link time via the
inventorycrate. - registration
- Handler registration — pairs route metadata with a type-erased Axum handler.
- resolution
- Namespace resolution utilities.
- schema_
registry - Zod schema registration — collects TypeScript schema strings at link time.
Macros§
- router
- Auto-discovery router macro with optional module path filtering.
Functions§
- generate_
contract - Begin building a TypeScript contract from all discovered handlers.
Attribute Macros§
- contract
- Automatically generate TypeScript contract before
fn main()runs (debug builds only). - delete
- Shorthand for
#[orpc::route(method = "DELETE", path = "...")]. - get
- Shorthand for
#[orpc::route(method = "GET", path = "...")]. - namespace
- Apply a namespace prefix to all handlers within a module.
- patch
- Shorthand for
#[orpc::route(method = "PATCH", path = "...")]. - post
- Shorthand for
#[orpc::route(method = "POST", path = "...")]. - put
- Shorthand for
#[orpc::route(method = "PUT", path = "...")]. - route
- Annotate an Axum handler with explicit HTTP method and path.