Skip to main content

Operation

Struct Operation 

Source
pub struct Operation<Handler, Inputs = (), Args = (), Transform = ()> { /* private fields */ }
Expand description

Carries a typed operation declaration as first-order data.

Implementations§

Source§

impl<Handler> Operation<Handler>

Source

pub fn new(handler: Handler) -> Self

Carries an operation before selecting its HTTP input and output roles.

Source§

impl<Handler, Inputs, Args, Transform> Operation<Handler, Inputs, Args, Transform>

Source

pub fn declare<Method>( self, path: &str, ) -> Endpoint<Method, Handler, Inputs, Args, Transform>

Declares this operation at one path under one method selector, with no program around it.

A program that states many endpoints composes their routes rather than their types, so it needs each endpoint on its own. The named declarations below select one method each; this states the same thing for a method held as a type parameter.

Source§

impl<Handler, Inputs, Args, Transform> Operation<Handler, Inputs, Args, Transform>
where Inputs: WithAlg, Args: WithAlg,

Source

pub fn with<Input>( self, ) -> WithInput<Handler, Inputs, Args, Transform, Direct<Input>, Input>

Records an argument supplied directly in the interpreter’s input product.

Source

pub fn path<Input>( self, ) -> WithInput<Handler, Inputs, Args, Transform, Path<Input>, Input>

Records a path extractor whose value becomes the next handler argument.

Source

pub fn query<Input>( self, ) -> WithInput<Handler, Inputs, Args, Transform, Query<Input>, Input>
where Input: NamedValuesAlg,

Records a query extractor whose value becomes the next handler argument.

Source

pub fn body<Input>( self, ) -> WithInput<Handler, Inputs, Args, Transform, Body<Input>, Input>

Records a request-body extractor whose value becomes the next handler argument.

Source

pub fn form<Input>( self, ) -> WithInput<Handler, Inputs, Args, Transform, Form<Input>, Input>

Records a form-encoded request-body extractor whose value becomes the next handler argument.

Source

pub fn raw_body<Input>( self, ) -> WithInput<Handler, Inputs, Args, Transform, RawBody<Input>, Input>

Records the request body as it arrived, becoming the next handler argument.

Source

pub fn in_header<Input>( self, ) -> WithInput<Handler, Inputs, Args, Transform, Header<Input>, Input>
where Input: NamedValuesAlg,

Records an incoming header extractor whose value becomes the next handler argument.

Source

pub fn cookie<Input>( self, ) -> WithInput<Handler, Inputs, Args, Transform, Cookie<Input>, Input>
where Input: NamedValuesAlg,

Records a cookie extractor whose value becomes the next handler argument.

Source

pub fn multipart<Input>( self, ) -> WithInput<Handler, Inputs, Args, Transform, Multipart<Input>, Input>

Records a body arriving as parts, read into the next handler argument.

Source

pub fn auth<Input>( self, ) -> WithInput<Handler, Inputs, Args, Transform, Auth<Input>, Input>
where Input: NamedValuesAlg,

Records an authentication extractor whose value becomes the next handler argument.

Source

pub fn context<Input>( self, ) -> WithInput<Handler, Inputs, Args, Transform, Context<Input>, Input>

Records an endpoint-context extractor whose value becomes the next handler argument.

Source

pub fn out<Kind>( self, ) -> Operation<Handler, Inputs, Args, <Transform as CloseAlg<Kind>>::Closed>
where Transform: CloseAlg<Kind>,

Closes the declaration with the output kind Kind, inside every wrapper already stated.

The kind is interpreted only after the handler result type is known at the compilation boundary, so a downstream kind closes a declaration exactly as a built-in one does.

Source

pub fn status<const CODE: u16>( self, ) -> Operation<Handler, Inputs, Args, OpenWith<Transform, StatusOut<(), CODE>>>
where Transform: OpenAlg,

Answers with CODE, around what the rest of the declaration states.

Source

pub fn out_header<Name>( self, ) -> Operation<Handler, Inputs, Args, OpenWith<Transform, HeaderOut<(), Name>>>
where Transform: OpenAlg,

Answers with the handler’s header value, around what the rest of the declaration states.

The handler answers with the value and then with what the rest states: (value, rest).

Source

pub fn out_headers<Headers>( self, ) -> Operation<Handler, Inputs, Args, OpenWith<Transform, HeadersOut<(), Headers>>>
where Transform: OpenAlg, Headers: NamedValuesAlg,

Answers with the headers the handler’s named product states, around what the rest states.

The output twin of Operation::in_header: each member of Headers is one header, named by its member name, and the handler answers with (headers, rest).

Source

pub fn result( self, ) -> Operation<Handler, Inputs, Args, OpenWith<Transform, ResultOut<()>>>
where Transform: OpenAlg,

Answers with what the rest of the declaration states when the handler succeeded, and with what its failure means otherwise.

Source§

impl<Handler, Inputs, Args, Transform> Operation<Handler, Inputs, Args, Transform>
where Inputs: WithAlg, Args: WithAlg,

Source

pub fn json( self, ) -> Operation<Handler, Inputs, Args, <Transform as CloseAlg<JsonOut>>::Closed>
where Transform: CloseAlg<JsonOut>,

Closes the declaration with JSON output meaning.

Source

pub fn file( self, ) -> Operation<Handler, Inputs, Args, <Transform as CloseAlg<FileOut>>::Closed>
where Transform: CloseAlg<FileOut>,

Closes the declaration with streamed-file output meaning.

Source

pub fn text( self, ) -> Operation<Handler, Inputs, Args, <Transform as CloseAlg<TextOut>>::Closed>
where Transform: CloseAlg<TextOut>,

Closes the declaration with plain-text output meaning.

Source

pub fn html( self, ) -> Operation<Handler, Inputs, Args, <Transform as CloseAlg<HtmlOut>>::Closed>
where Transform: CloseAlg<HtmlOut>,

Closes the declaration with HTML output meaning.

Source

pub fn bytes( self, ) -> Operation<Handler, Inputs, Args, <Transform as CloseAlg<BytesOut>>::Closed>
where Transform: CloseAlg<BytesOut>,

Closes the declaration with raw-byte output meaning.

Source

pub fn empty( self, ) -> Operation<Handler, Inputs, Args, <Transform as CloseAlg<EmptyOut>>::Closed>
where Transform: CloseAlg<EmptyOut>,

Closes the declaration with empty output meaning.

Source

pub fn redirect( self, ) -> Operation<Handler, Inputs, Args, <Transform as CloseAlg<RedirectOut>>::Closed>
where Transform: CloseAlg<RedirectOut>,

Closes the declaration with redirect output meaning.

Source

pub fn stream( self, ) -> Operation<Handler, Inputs, Args, <Transform as CloseAlg<StreamOut>>::Closed>
where Transform: CloseAlg<StreamOut>,

Closes the declaration with streamed output meaning.

Source§

impl<Handler, Inputs, Args, Transform> Operation<Handler, Inputs, Args, Transform>
where Inputs: WithAlg, Args: WithAlg,

Source

pub fn get(self, path: &str) -> Endpoint<Get, Handler, Inputs, Args, Transform>

Declares this operation at an exact path, answered under GET.

This is the same thing the declaration of that name on RouteProgram states, for one endpoint standing on its own rather than one inside a composition.

Source

pub fn post( self, path: &str, ) -> Endpoint<Post, Handler, Inputs, Args, Transform>

Declares this operation at an exact path, answered under POST.

This is the same thing the declaration of that name on RouteProgram states, for one endpoint standing on its own rather than one inside a composition.

Source

pub fn put(self, path: &str) -> Endpoint<Put, Handler, Inputs, Args, Transform>

Declares this operation at an exact path, answered under PUT.

This is the same thing the declaration of that name on RouteProgram states, for one endpoint standing on its own rather than one inside a composition.

Source

pub fn patch( self, path: &str, ) -> Endpoint<Patch, Handler, Inputs, Args, Transform>

Declares this operation at an exact path, answered under PATCH.

This is the same thing the declaration of that name on RouteProgram states, for one endpoint standing on its own rather than one inside a composition.

Source

pub fn delete( self, path: &str, ) -> Endpoint<Delete, Handler, Inputs, Args, Transform>

Declares this operation at an exact path, answered under DELETE.

This is the same thing the declaration of that name on RouteProgram states, for one endpoint standing on its own rather than one inside a composition.

Source

pub fn head( self, path: &str, ) -> Endpoint<Head, Handler, Inputs, Args, Transform>

Declares this operation at an exact path, answered under HEAD.

This is the same thing the declaration of that name on RouteProgram states, for one endpoint standing on its own rather than one inside a composition.

Source

pub fn options( self, path: &str, ) -> Endpoint<Options, Handler, Inputs, Args, Transform>

Declares this operation at an exact path, answered under OPTIONS.

This is the same thing the declaration of that name on RouteProgram states, for one endpoint standing on its own rather than one inside a composition.

Source

pub fn trace( self, path: &str, ) -> Endpoint<Trace, Handler, Inputs, Args, Transform>

Declares this operation at an exact path, answered under TRACE.

This is the same thing the declaration of that name on RouteProgram states, for one endpoint standing on its own rather than one inside a composition.

Source

pub fn connect( self, path: &str, ) -> Endpoint<Connect, Handler, Inputs, Args, Transform>

Declares this operation at an exact path, answered under CONNECT.

This is the same thing the declaration of that name on RouteProgram states, for one endpoint standing on its own rather than one inside a composition.

Trait Implementations§

Source§

impl<Handler: Debug, Inputs: Debug, Args: Debug, Transform: Debug> Debug for Operation<Handler, Inputs, Args, Transform>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Handler, Inputs, Args, Transform> Freeze for Operation<Handler, Inputs, Args, Transform>
where Handler: Freeze, PhantomData<fn(Inputs, Args, Transform)>: Freeze,

§

impl<Handler, Inputs, Args, Transform> RefUnwindSafe for Operation<Handler, Inputs, Args, Transform>
where Handler: RefUnwindSafe, PhantomData<fn(Inputs, Args, Transform)>: RefUnwindSafe,

§

impl<Handler, Inputs, Args, Transform> Send for Operation<Handler, Inputs, Args, Transform>
where Handler: Send, PhantomData<fn(Inputs, Args, Transform)>: Send,

§

impl<Handler, Inputs, Args, Transform> Sync for Operation<Handler, Inputs, Args, Transform>
where Handler: Sync, PhantomData<fn(Inputs, Args, Transform)>: Sync,

§

impl<Handler, Inputs, Args, Transform> Unpin for Operation<Handler, Inputs, Args, Transform>
where Handler: Unpin, PhantomData<fn(Inputs, Args, Transform)>: Unpin,

§

impl<Handler, Inputs, Args, Transform> UnsafeUnpin for Operation<Handler, Inputs, Args, Transform>
where Handler: UnsafeUnpin, PhantomData<fn(Inputs, Args, Transform)>: UnsafeUnpin,

§

impl<Handler, Inputs, Args, Transform> UnwindSafe for Operation<Handler, Inputs, Args, Transform>
where Handler: UnwindSafe, PhantomData<fn(Inputs, Args, Transform)>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<This> HttpOperationExt<This> for This

Source§

fn op<Handler>(&self, handler: Handler) -> Operation<Handler>

Starts an operation declaration without choosing extraction or conversion.

Source§

impl<This> HttpProgramExt<This> for This

Source§

fn program<Program>(&self, program: Program) -> Routes<'_, This>
where This: RouteAlg, Program: HttpProgramAlg<This, Route = <This as RouteAlg>::Route>,

Interprets a named program for further route composition.

Source§

fn compile_http<Program>( &self, program: Program, ) -> <Program as HttpProgramAlg<This>>::Route
where Program: HttpProgramAlg<This>,

Compiles a named HTTP program with this interpreter.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.