Expand description
§taut-rpc
End-to-end type-safe RPC between a Rust/axum server and a TypeScript client.
taut-rpc makes Rust types the single source of truth for an HTTP/SSE/WebSocket
API: a procedural macro records each procedure’s signature into an intermediate
representation (IR), and a separate codegen step turns that IR into a static
.ts client. Changing a Rust signature surfaces as a TypeScript compile error
at the call site, with no runtime schema fetch on boot.
This crate provides the public runtime API: the Router used to mount
procedures onto an axum::Router, the TautError trait that constrains
procedure error types, and the Validate bridge for input/output validation.
§v0.1 features
- Validation (Phase 4): the
Validatederive macro andvalidatemodule provide declarative input/output validation. Constraints are declared with#[validate(...)]attributes and emitted into the IR so the generated TypeScript client can mirror server-side checks. Seevalidate::run,validate::collect,validate::nested, andvalidate::checkfor the runtime helpers used by generated code.
See SPEC.md for
the full design — wire format, type mapping, IR schema, and versioning rules.
The IR_VERSION constant tracks SPEC §9.
For ergonomic imports use use taut_rpc::prelude::*; — see prelude.
Re-exports§
pub use dump::dump_if_requested;pub use dump::ir_json;pub use error::StandardError;pub use error::TautError;pub use procedure::ProcedureBody;pub use procedure::ProcedureDescriptor;pub use procedure::ProcedureHandler;pub use procedure::ProcedureResult;pub use procedure::StreamFrame;pub use procedure::StreamHandler;pub use procedure::UnaryHandler;pub use router::ProcKindRuntime;pub use router::Router;pub use types::TautType;pub use validate::Constraint;pub use validate::Validate;pub use validate::ValidationError;
Modules§
- dump
- IR-dump entrypoint used by
cargo taut gen. See SPEC §2. - error
- Error contract for taut-rpc procedures. See SPEC §3.3.
- ir
- Intermediate representation (IR) types for taut-rpc.
- prelude
- Convenient re-exports for typical taut-rpc users.
- procedure
- Type-erased procedure contract used by
#[rpc]-emitted code to register a procedure with thecrate::router::Router. - router
- Server-side procedure router for taut-rpc. See SPEC §5.
- type_
map - Rust → TypeScript type mapping. See SPEC §3.
- types
- Bridge between Rust types and the taut-rpc IR.
- validate
- Validation bridge for taut-rpc. See SPEC §7.
- wire
- Wire format types for taut-rpc (server <-> client JSON shapes).
Constants§
- IR_
VERSION - Current IR schema version. Tracks SPEC §9 — codegen rejects mismatches.
Attribute Macros§
- rpc
- Marks an
async fnas ataut-rpcprocedure.
Derive Macros§
- Taut
Error - Derives
taut-rpc’sTautErrortrait for an enum, supplyingcode()(default: variant name insnake_case) andhttp_status()(default: 400) per variant. Both can be overridden via#[taut(code = "...", status = 401)]. See SPEC §3.3. - Type
- Derives
taut-rpc’s type-registration trait for a struct or enum so the type appears in the IR and gets a TypeScript definition emitted. - Validate
- Derives
taut-rpc’sValidatetrait for a struct or enum, walking each field’s#[taut(...)]constraints (min,max,length,pattern,email,url,custom) and dispatching to the correspondingvalidate::check::*runtime helpers. Foreign#[taut(...)]keys owned by other derives (rename,tag,optional,undefined,code,status) are silently ignored. See SPEC §7.