axum-syntax-custom-extractors

Guide Axum 0.7/0.8 custom extractor trait selection and rejection wiring.

Updated May 20, 2026
One-click install
npx skills add https://github.com/Impertio-Studio/Axum-Claude-Skill-Package --skill axum-syntax-custom-extractors
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: axum-syntax-custom-extractors
Source: https://github.com/Impertio-Studio/Axum-Claude-Skill-Package/tree/main/skills/source/axum-syntax/axum-syntax-custom-extractors
Command: npx skills add https://github.com/Impertio-Studio/Axum-Claude-Skill-Package --skill axum-syntax-custom-extractors

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Custom extractors often fail in Axum due to version-specific async trait rules, incorrect FromRequest vs FromRequestParts selection, missing or incompatible rejection types, or subtle handler-argument ordering constraints.

Core Features & Use Cases

  • Correct trait choice (body vs parts): Selects FromRequestParts for extractors that do not consume the body and FromRequest for extractors that do, ensuring the body extractor is placed last.
  • Version-correct async implementation: Explains Axum 0.7’s #[async_trait] requirement versus Axum 0.8’s native async fn in traits, preventing signature mismatches.
  • Safe rejection wiring: Ensures Rejection implements IntoResponse, and shows how to remap inner rejection types when wrapping existing extractors (e.g., wrapping Json).
  • State and substate access: Covers extracting one resource from composite state via FromRef.
  • Derive macro usage: Documents #[derive(FromRequest)] / #[derive(FromRequestParts)] and attributes like via(...), rejection(...), and state(...).
  • Common anti-pattern fixes: Resolves compile-time and “Handler is not satisfied” failures caused by ambiguous extractor implementations and misordered arguments.

Quick Start

Ask Claude to produce a custom Axum 0.8 extractor that reads request parts or consumes the body as appropriate, with a Rejection that implements IntoResponse and an example handler that places it in the correct argument position.

Frequently Asked Questions about axum-syntax-custom-extractors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use FromRequestParts versus FromRequest for an Axum custom extractor?

To implement custom extractors in Axum 0.7, apply the #[async_trait] macro to your trait implementation blocks. Axum 0.8 removes this requirement, allowing you to use native async fn syntax directly in trait implementations without macro wrappers.

Why does my Axum handler fail to compile with a "Handler is not satisfied" error when using custom extractors?

When wrapping existing Axum extractors like Json in a custom extractor, you must remap the inner rejection type into your own rejection type. Your custom Rejection type must implement the IntoResponse trait so extraction failures deterministically become valid HTTP responses.

How do I extract a specific substate from composite Axum state using FromRef?

Use the FromRef trait to extract a specific resource from your composite Axum application state. This allows your custom extractor to access individual substates without requiring the entire state struct to be cloned or passed in its entirety.

Can I use derive macros to generate Axum custom extractors with unified rejections?

Yes, you can use #[derive(FromRequest)] or #[derive(FromRequestParts)] with attributes like via(...), rejection(...), and state(...) to generate Axum custom extractors. This approach helps unify rejection types and simplifies extractor implementation.