pub trait PlexusRequest: Sized {
// Required method
fn extract(ctx: &RawRequestContext) -> Result<Self, PlexusError>;
// Provided method
fn request_schema() -> Option<Value> { ... }
}Expand description
Trait implemented by #[derive(PlexusRequest)] structs.
A PlexusRequest struct is a typed view of an inbound HTTP request, where
each field is extracted from a specific part of the raw context (cookie,
header, query string, peer address, or auth context).
§Deriving
Use the PlexusRequest derive macro from plexus_macros:
use plexus_macros::PlexusRequest;
#[derive(PlexusRequest)]
struct MyRequest {
#[from_cookie("access_token")]
auth_token: String,
#[from_header("origin")]
origin: Option<String>,
#[from_peer]
peer_addr: Option<std::net::SocketAddr>,
}Required Methods§
Sourcefn extract(ctx: &RawRequestContext) -> Result<Self, PlexusError>
fn extract(ctx: &RawRequestContext) -> Result<Self, PlexusError>
Extract a typed request from the raw HTTP context.
Provided Methods§
Sourcefn request_schema() -> Option<Value>
fn request_schema() -> Option<Value>
Return the JSON Schema for this request type as a serde_json::Value.
The schema includes x-plexus-source metadata on each field describing
where the field value is extracted from (cookie, header, peer, etc.).
The default implementation returns None; the #[derive(PlexusRequest)]
macro generates a concrete implementation with the full schema.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".