Skip to main content

Crate kynos_macros

Crate kynos_macros 

Source
Expand description

Procedural macros for the Kynos REST API framework.

Nothing here is meant to be used directly: every macro is re-exported from kynos, and the documentation lives next to the trait each one implements.

§Why the route attributes exist

Kynos deliberately has no attribute DSL restating a handler’s signature. utoipa’s #[utoipa::path(responses(...))] is written by hand beside the code it describes, and nothing keeps the two in step — which is the single most common way a generated OpenAPI document ends up wrong.

The route attributes therefore carry only what the types cannot: the method, the path, and prose. Parameters come from the handler’s arguments, responses from its return type, and neither is restated anywhere.

What the attribute does add is compile-time checking the builder form cannot do — chiefly that a path template’s variables match the handler’s path parameters.

§Why the examples here are ignored

Every expansion names ::kynos::…, which this crate cannot depend on, so a doctest here would not compile whatever the derive emitted. The compiled demonstrations live in crates/kynos/tests/derives.rs and the framework’s examples; AGENTS.md records the carve-out.

Macros§

assets
Compiles a directory into the binary as a described asset set.
path
A path template validated at compile time.
routes
Collects operations for mounting.

Attribute Macros§

delete
Declares a DELETE operation. See get for the syntax.
get
Declares a GET operation.
head
Declares a HEAD operation. See get for the syntax.
operation
Declares an operation for a method with no dedicated attribute.
options
Declares an OPTIONS operation. See get for the syntax.
patch
Declares a PATCH operation. See get for the syntax.
post
Declares a POST operation. See get for the syntax.
put
Declares a PUT operation. See get for the syntax.
query
Declares a QUERY operation.
trace
Declares a TRACE operation. See get for the syntax.

Derive Macros§

ApiError
Maps an error type to RFC 9457 problem details.
CookieParams
Declares a group of request cookies.
HeaderParams
Declares a group of request or response headers.
MultipartForm
Declares the fields of a multipart/form-data body, in both directions.
PathParams
Declares a group of path parameters.
Provider
Declares an application context, emitting one Provides implementation per field.
QueryParams
Declares a group of query parameters.
Reply
Declares a closed set of responses, one variant per status.
Schema
Describes a type as JSON Schema.
SecurityScheme
Declares a security scheme.
Tag
Declares a tag.