Trait aide::operation::OperationOutput

source ·
pub trait OperationOutput {
    type Inner;

    // Provided methods
    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§

source

type Inner

The type that is used in examples.

§Examples

In case of Json<T>, this should be T, whereas for String it should be Self.

Provided Methods§

source

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.

source

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl OperationOutput for FormRejection

Available on crate feature axum only.
§

type Inner = FormRejection

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl OperationOutput for JsonRejection

Available on crate feature axum only.
§

type Inner = JsonRejection

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl OperationOutput for ()

§

type Inner = ()

source§

fn operation_response( _ctx: &mut GenContext, _operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl OperationOutput for String

§

type Inner = String

source§

fn operation_response( _ctx: &mut GenContext, _operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl OperationOutput for Vec<u8>

§

type Inner = Vec<u8>

source§

fn operation_response( _ctx: &mut GenContext, _operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl OperationOutput for PrivateCookieJar

Available on crate features axum-extra and axum and axum-extra-cookie-private only.
§

type Inner = ()

source§

impl OperationOutput for CookieJar

Available on crate features axum-extra and axum and axum-extra-cookie only.
§

type Inner = ()

source§

impl OperationOutput for Redirect

Available on crate feature axum only.
§

type Inner = Redirect

source§

fn operation_response( _ctx: &mut GenContext, _operation: &mut Operation ) -> Option<Response>

source§

impl OperationOutput for Bytes

Available on crate feature bytes only.
§

type Inner = Bytes

source§

fn operation_response( _ctx: &mut GenContext, _operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl OperationOutput for BytesMut

Available on crate feature bytes only.
§

type Inner = BytesMut

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl OperationOutput for StatusCode

Available on crate feature http only.
source§

impl<'a> OperationOutput for &'a str

§

type Inner = &'a str

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl<'a> OperationOutput for &'a [u8]

§

type Inner = &'a [u8]

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl<'a> OperationOutput for Cow<'a, str>

§

type Inner = Cow<'a, str>

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl<'a> OperationOutput for Cow<'a, [u8]>

§

type Inner = Cow<'a, [u8]>

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl<B> OperationOutput for Response<B>

Available on crate feature http only.
§

type Inner = Response<B>

source§

impl<T1, T2> OperationOutput for (T1, T2)

source§

impl<T1, T2, T3> OperationOutput for (T1, T2, T3)

source§

impl<T1, T2, T3, T4> OperationOutput for (T1, T2, T3, T4)

source§

impl<T1, T2, T3, T4, T5> OperationOutput for (T1, T2, T3, T4, T5)

source§

impl<T1, T2, T3, T4, T5, T6> OperationOutput for (T1, T2, T3, T4, T5, T6)

source§

impl<T1, T2, T3, T4, T5, T6, T7> OperationOutput for (T1, T2, T3, T4, T5, T6, T7)

source§

impl<T1, T2, T3, T4, T5, T6, T7, T8> OperationOutput for (T1, T2, T3, T4, T5, T6, T7, T8)

source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9> OperationOutput for (T1, T2, T3, T4, T5, T6, T7, T8, T9)

source§

impl<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> OperationOutput for (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)

source§

impl<T> OperationOutput for Option<T>
where T: OperationOutput,

§

type Inner = <T as OperationOutput>::Inner

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl<T> OperationOutput for Box<T>
where T: OperationOutput,

§

type Inner = <T as OperationOutput>::Inner

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl<T> OperationOutput for Rc<T>
where T: OperationOutput,

§

type Inner = <T as OperationOutput>::Inner

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl<T> OperationOutput for Arc<T>
where T: OperationOutput,

§

type Inner = <T as OperationOutput>::Inner

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl<T> OperationOutput for Form<T>
where T: JsonSchema,

Available on crate feature axum only.
§

type Inner = T

source§

fn operation_response( ctx: &mut GenContext, _operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl<T> OperationOutput for Json<T>
where T: JsonSchema,

Available on crate feature axum only.
§

type Inner = T

source§

fn operation_response( ctx: &mut GenContext, _operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl<T> OperationOutput for Html<T>

Available on crate feature axum only.
§

type Inner = String

source§

fn operation_response( _ctx: &mut GenContext, _operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

source§

impl<T, E> OperationOutput for Result<T, E>

§

type Inner = T

source§

fn operation_response( ctx: &mut GenContext, operation: &mut Operation ) -> Option<Response>

source§

fn inferred_responses( ctx: &mut GenContext, operation: &mut Operation ) -> Vec<(Option<u16>, Response)>

Implementors§