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, 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<NewTransform>(self) -> Operation<Handler, Inputs, Args, NewTransform>

Replaces the declaration’s output-kind marker without converting a value.

The selected kind is interpreted only after the handler result type is known at the compilation boundary.

Source

pub fn json(self) -> Operation<Handler, Inputs, Args, JsonOut>

Marks the inferred handler result for JSON interpretation.

Source

pub fn file(self) -> Operation<Handler, Inputs, Args, FileOut>

Marks the inferred handler result for streamed-file interpretation.

Source

pub fn text(self) -> Operation<Handler, Inputs, Args, TextOut>

Marks the inferred handler result for plain-text interpretation.

Source

pub fn html(self) -> Operation<Handler, Inputs, Args, HtmlOut>

Marks the inferred handler result for HTML interpretation.

Source

pub fn bytes(self) -> Operation<Handler, Inputs, Args, BytesOut>

Marks the inferred handler result for raw-byte interpretation.

Source

pub fn empty(self) -> Operation<Handler, Inputs, Args, EmptyOut>

Marks the inferred handler result for empty interpretation.

Source

pub fn redirect(self) -> Operation<Handler, Inputs, Args, RedirectOut>

Marks the inferred handler result for redirect interpretation.

Source

pub fn stream(self) -> Operation<Handler, Inputs, Args, StreamOut>

Marks the inferred handler result for streamed interpretation.

Source

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

Answers with CODE and the body already stated.

Source

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

Answers with an outgoing response header the handler states, beside the body already stated.

The handler answers with the header’s value and the body, so a value an endpoint cannot know is one the handler still states.

Source

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

Answers with what the handler’s failure means when it fails.

The kind already stated answers the successful result, so .json().result() states JSON on success and the meaning of the failure otherwise.

Source§

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

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> HttpProgramExt<This> for This

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.