Trait aide::operation::OperationOutput
source · [−]pub trait OperationOutput {
type Inner;
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response> { ... }
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)> { ... }
}
Expand description
A trait for operation output schema generation.
This can be implemented for types that can describe their own output schema.
All method implementations are optional.
For simpler cases or wrappers the OperationIo
derive macro
can be used to implement this trait.
Required Associated Types
Provided Methods
sourcefn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
Return a response documentation for this type, alternatively modify the operation if required.
This method gets mutable access to the entire operation, it’s the implementer’s responsibility to detect errors and only modify the operation as much as needed.
Note that this function can be called multiple times for the same operation and should be idempotent.
There are reusable helpers in aide::operation
to help with both boilerplate and error detection.
sourcefn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
Inferred responses are used when the type is used as a request handler return type.
The function is supposed to return (status code, response)
pairs,
if the status code is not specified, the response is assumed to be
a default response.
As an example Result<T, E>
could
return (Some(200), T::operation_response(..))
and
(None, E::operation_response(..))
to indicate
a successful response and a default error.
This function can be called after or before operation_response
,
it’s important for the implementation to be idempotent.
Implementations on Foreign Types
sourceimpl OperationOutput for Bytes
Available on crate feature bytes
only.
impl OperationOutput for Bytes
bytes
only.type Inner = Bytes
fn operation_response(
_ctx: &mut GenContext,
_operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl OperationOutput for BytesMut
Available on crate feature bytes
only.
impl OperationOutput for BytesMut
bytes
only.type Inner = BytesMut
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<B> OperationOutput for Response<B>
Available on crate feature http
only.
impl<B> OperationOutput for Response<B>
http
only.sourceimpl OperationOutput for StatusCode
Available on crate feature http
only.
impl OperationOutput for StatusCode
http
only.type Inner = StatusCode
sourceimpl<T, E> OperationOutput for Result<T, E>where
T: OperationOutput,
E: OperationOutput,
impl<T, E> OperationOutput for Result<T, E>where
T: OperationOutput,
E: OperationOutput,
type Inner = T
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<T> OperationOutput for Option<T>where
T: OperationOutput,
impl<T> OperationOutput for Option<T>where
T: OperationOutput,
type Inner = <T as OperationOutput>::Inner
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<T> OperationOutput for Box<T>where
T: OperationOutput,
impl<T> OperationOutput for Box<T>where
T: OperationOutput,
type Inner = <T as OperationOutput>::Inner
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<T> OperationOutput for Rc<T>where
T: OperationOutput,
impl<T> OperationOutput for Rc<T>where
T: OperationOutput,
type Inner = <T as OperationOutput>::Inner
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<T> OperationOutput for Arc<T>where
T: OperationOutput,
impl<T> OperationOutput for Arc<T>where
T: OperationOutput,
type Inner = <T as OperationOutput>::Inner
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl OperationOutput for String
impl OperationOutput for String
type Inner = String
fn operation_response(
_ctx: &mut GenContext,
_operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<'a> OperationOutput for &'a str
impl<'a> OperationOutput for &'a str
type Inner = &'a str
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<'a> OperationOutput for Cow<'a, str>
impl<'a> OperationOutput for Cow<'a, str>
type Inner = Cow<'a, str>
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl OperationOutput for ()
impl OperationOutput for ()
type Inner = ()
fn operation_response(
_ctx: &mut GenContext,
_operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl OperationOutput for Vec<u8>
impl OperationOutput for Vec<u8>
type Inner = Vec<u8, Global>
fn operation_response(
_ctx: &mut GenContext,
_operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<'a> OperationOutput for &'a [u8]
impl<'a> OperationOutput for &'a [u8]
type Inner = &'a [u8]
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<'a> OperationOutput for Cow<'a, [u8]>
impl<'a> OperationOutput for Cow<'a, [u8]>
type Inner = Cow<'a, [u8]>
fn operation_response(
ctx: &mut GenContext,
operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<T1, T2> OperationOutput for (T1, T2)
impl<T1, T2> OperationOutput for (T1, T2)
type Inner = Infallible
sourceimpl<T> OperationOutput for Json<T>where
T: JsonSchema,
Available on crate feature axum
only.
impl<T> OperationOutput for Json<T>where
T: JsonSchema,
axum
only.type Inner = T
fn operation_response(
ctx: &mut GenContext,
_operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<T> OperationOutput for Form<T>where
T: JsonSchema,
Available on crate feature axum
only.
impl<T> OperationOutput for Form<T>where
T: JsonSchema,
axum
only.type Inner = T
fn operation_response(
ctx: &mut GenContext,
_operation: &mut Operation
) -> Option<Response>
fn inferred_responses(
ctx: &mut GenContext,
operation: &mut Operation
) -> Vec<(Option<u16>, Response)>
sourceimpl<T> OperationOutput for Html<T>
Available on crate feature axum
only.
impl<T> OperationOutput for Html<T>
axum
only.