pub trait EndpointWithSchema {
type Output: IntoResponse + Send + ResponseSchema;
type Placeholders: PathExtractor<Body> + Clone + Sync + OpenapiType;
type Params: QueryStringExtractor<Body> + Clone + Sync + OpenapiType;
type Body: RequestBody + Send;
// Required methods
fn http_method() -> Method;
fn uri() -> Cow<'static, str>;
fn operation_verb() -> Option<&'static str>;
fn handle(
state: &mut State,
placeholders: Self::Placeholders,
params: Self::Params,
body: Option<Self::Body>,
) -> BoxFuture<'_, Self::Output>;
// Provided methods
fn has_placeholders() -> bool { ... }
fn needs_params() -> bool { ... }
fn needs_body() -> bool { ... }
fn wants_auth() -> bool { ... }
fn operation_id() -> Option<String> { ... }
fn description() -> Option<String> { ... }
}Required Associated Types§
Sourcetype Output: IntoResponse + Send + ResponseSchema
type Output: IntoResponse + Send + ResponseSchema
The output type that provides the response.
Sourcetype Placeholders: PathExtractor<Body> + Clone + Sync + OpenapiType
type Placeholders: PathExtractor<Body> + Clone + Sync + OpenapiType
The type that parses the URI placeholders. Use NoopExtractor if has_placeholders()
returns false.
Sourcetype Params: QueryStringExtractor<Body> + Clone + Sync + OpenapiType
type Params: QueryStringExtractor<Body> + Clone + Sync + OpenapiType
The type that parses the request parameters. Use NoopExtractor if needs_params()
returns false.
Sourcetype Body: RequestBody + Send
type Body: RequestBody + Send
The type to parse the body into. Use () if needs_body() returns false.
Required Methods§
Sourcefn http_method() -> Method
fn http_method() -> Method
The HTTP Verb of this endpoint.
Sourcefn operation_verb() -> Option<&'static str>
fn operation_verb() -> Option<&'static str>
The verb used for generating an operation id if Self::operation_id returns None.
For example read, read_all, create, update etc.
Provided Methods§
Sourcefn has_placeholders() -> bool
fn has_placeholders() -> bool
Returns true iff the URI contains placeholders. false by default.
Sourcefn needs_params() -> bool
fn needs_params() -> bool
Returns true iff the request parameters should be parsed. false by default.
Sourcefn needs_body() -> bool
fn needs_body() -> bool
Returns true iff the request body should be parsed. false by default.
Sourcefn wants_auth() -> bool
fn wants_auth() -> bool
Returns true if the request wants to know the auth status of the client. false by default.
Sourcefn operation_id() -> Option<String>
fn operation_id() -> Option<String>
Replace the automatically generated operation id with a custom one. Only relevant for the OpenAPI Specification.
Sourcefn description() -> Option<String>
fn description() -> Option<String>
Add a description to the openapi specification. Usually taken from the rustdoc comment when using the proc macro.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.