Expand description
Typed response wrapper for compile-time return type enforcement.
Strict<E> wraps an endpoint to enforce that the handler returns
the exact type declared in the API spec. Without Strict, handlers
can return any impl IntoResponse regardless of the declared Res.
§Example
ⓘ
type API = (
// Handler MUST return Json<Vec<User>> — compiler enforced
Strict<GetEndpoint<UsersPath, Json<Vec<User>>>>,
// Handler can return anything implementing IntoResponse
GetEndpoint<TagsPath, TagsResponse>,
);
// This compiles — return type matches Res:
async fn list_users() -> Json<Vec<User>> { Json(vec![]) }
// This would NOT compile — String ≠ Json<Vec<User>>:
// async fn list_users() -> String { "nope".into() }Structs§
- Strict
- An endpoint that enforces the handler’s return type matches
Res. - Strict
With Body - Marker for strict handlers with a body extractor.
Traits§
- HasErr
Type - Trait to extract the Err type from an endpoint.
- HasRes
Type - Trait to extract the Res type from an endpoint.
- Strict
Endpoint - Trait to extract binding info from a Strict endpoint.
- Strict
Handler - A handler that returns exactly type
Res.
Functions§
- bind_
strict - Bind a handler to a
Strict<E>endpoint.