Expand description
Procedural macros for taut-rpc.
This crate is an implementation detail of taut-rpc; users should depend on
taut-rpc and import the macros via its re-exports rather than depending on
this crate directly.
Four macros are provided through Phase 4:
#[rpc]— attribute macro applied to a freeasync fn(queries and mutations only in Phase 1;#[rpc(stream)]lands in Phase 3). Supports#[rpc]and#[rpc(method = "GET")]. See SPEC §2 (architecture) and §4 (wire format).#[derive(Type)]— derive macro that records a Rust type in the IR so the codegen step can emit a corresponding TypeScript definition. Works on structs (named, tuple, unit) and enums (unit, tuple, struct variants). See SPEC §3 (type mapping).#[derive(TautError)]— derive macro that supplies theTautErrortrait impl (per-variantcode()andhttp_status()) for an enum. See SPEC §3.3 (errors).#[derive(Validate)]— derive macro that emits theValidatetrait impl from per-field#[taut(...)]constraint attributes (min,max,length,pattern,email,url,custom). See SPEC §7 (validation bridge).
All macros report errors via syn::Error::into_compile_error so failures
surface as compiler diagnostics rather than panics.
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.