zino_ntex

Struct Extractor

Source
pub struct Extractor<T>(/* private fields */);
Expand description

An HTTP request extractor.

Trait Implementations§

Source§

impl<T> Deref for Extractor<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> DerefMut for Extractor<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl From<Extractor<HttpRequest>> for HttpRequest

Source§

fn from(extractor: Extractor<HttpRequest>) -> Self

Converts to this type from the input type.
Source§

impl From<HttpRequest> for Extractor<HttpRequest>

Source§

fn from(request: HttpRequest) -> Self

Converts to this type from the input type.
Source§

impl<Err: ErrorRenderer> From<WebRequest<Err>> for Extractor<HttpRequest>

Source§

fn from(request: WebRequest<Err>) -> Self

Converts to this type from the input type.
Source§

impl FromRequest<DefaultError> for Extractor<HttpRequest>

Source§

type Error = Infallible

The associated error which can be returned.
Source§

async fn from_request( req: &HttpRequest, payload: &mut Payload, ) -> Result<Self, Self::Error>

Convert request to a Self
Source§

impl RequestContext for Extractor<HttpRequest>

Source§

type Method = Method

The method type.
Source§

type Uri = Uri

The uri type.
Source§

fn request_method(&self) -> &Self::Method

Returns the request method.
Source§

fn original_uri(&self) -> &Self::Uri

Returns the original request URI regardless of nesting.
Source§

fn matched_route(&self) -> Cow<'_, str>

Returns the route that matches the request.
Source§

fn request_path(&self) -> &str

Returns the request path regardless of nesting.
Source§

fn get_query_string(&self) -> Option<&str>

Gets the query string of the request.
Source§

fn get_header(&self, name: &str) -> Option<&str>

Gets an HTTP header value with the given name.
Source§

fn client_ip(&self) -> Option<IpAddr>

Returns the client’s remote IP.
Source§

fn get_context(&self) -> Option<Context>

Gets the request context.
Source§

fn get_data<T: Clone + Send + Sync + 'static>(&self) -> Option<T>

Gets the request scoped data.
Source§

fn set_data<T: Clone + Send + Sync + 'static>(&mut self, value: T) -> Option<T>

Sets the request scoped data and returns the old value if an item of this type was already stored.
Source§

async fn read_body_bytes(&mut self) -> Result<Vec<u8>, Error>

Reads the entire request body into a byte buffer.
Source§

fn path_segments(&self) -> Vec<&str>

Returns the request path segments.
Source§

fn new_context(&self) -> Context

Creates a new request context.
Source§

fn get_trace_context(&self) -> Option<TraceContext>

Returns the trace context by parsing the traceparent and tracestate header values.
Source§

fn new_trace_context(&self) -> TraceContext

Creates a new TraceContext.
Source§

fn start_time(&self) -> Instant

Returns the start time.
Source§

fn instance(&self) -> String

Returns the instance.
Source§

fn request_id(&self) -> Uuid

Returns the request ID.
Source§

fn trace_id(&self) -> Uuid

Returns the trace ID.
Source§

fn session_id(&self) -> Option<String>

Returns the session ID.
Source§

fn data_type(&self) -> Option<&str>

Gets the data type by parsing the content-type header. Read more
Source§

fn get_param(&self, name: &str) -> Option<&str>

Gets the route parameter by name. The name should not include :, *, { or }. Read more
Source§

fn decode_param(&self, name: &str) -> Result<Cow<'_, str>, Rejection>

Decodes the UTF-8 percent-encoded route parameter by name.
Source§

fn parse_param<T>(&self, name: &str) -> Result<T, Rejection>
where T: FromStr, <T as FromStr>::Err: Into<Error>,

Parses the route parameter by name as an instance of type T. The name should not include :, *, { or }.
Source§

fn get_query(&self, name: &str) -> Option<&str>

Gets the query value of the URI by name. Read more
Source§

fn decode_query(&self, name: &str) -> Result<Cow<'_, str>, Rejection>

Decodes the UTF-8 percent-encoded query value of the URI by name.
Source§

fn parse_query<T>(&self) -> Result<T, Rejection>

Parses the query as an instance of type T. Returns a default value of T when the query is empty. If the query has a timestamp parameter, it will be used to prevent replay attacks.
Source§

async fn parse_body<T>(&mut self) -> Result<T, Rejection>

Parses the request body as an instance of type T. Read more
Source§

async fn parse_multipart(&mut self) -> Result<Multipart<'_>, Rejection>

Parses the request body as a multipart, which is commonly used with file uploads.
Source§

async fn parse_file(&mut self) -> Result<NamedFile, Rejection>

Parses the request body as a file.
Source§

async fn parse_files(&mut self) -> Result<Vec<NamedFile>, Rejection>

Parses the request body as a list of files.
Source§

async fn parse_form_data<T>(&mut self) -> Result<(T, Vec<NamedFile>), Rejection>

Parses the multipart/form-data as an instance of type T and a list of files.
Source§

fn query_validation<S>( &self, query: &mut Query, ) -> Result<Response<S>, Rejection>
where Self: Sized, S: ResponseCode,

Returns a Response or Rejection from a model query validation. The data is extracted from parse_query().
Source§

async fn model_validation<M, S>( &mut self, model: &mut M, ) -> Result<Response<S>, Rejection>
where Self: Sized, M: ModelHooks, S: ResponseCode,

Returns a Response or Rejection from a model validation. The data is extracted from parse_body().
Source§

async fn fetch( &self, url: &str, options: Option<&Map<String, Value>>, ) -> Result<Response, Error>

Makes an HTTP request to the provided URL.
Source§

async fn fetch_json<T>( &self, url: &str, options: Option<&Map<String, Value>>, ) -> Result<T, Error>

Makes an HTTP request to the provided URL and deserializes the response body via JSON.
Source§

fn subscription(&self) -> Subscription

Constructs a new subscription instance.
Source§

fn cloud_event(&self, event_type: Cow<'static, str>, data: Value) -> CloudEvent

Constructs a new cloud event instance.
Source§

impl<Err: ErrorRenderer> TryFrom<Extractor<HttpRequest>> for WebRequest<Err>

Source§

type Error = NtexRejection

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

fn try_from(extractor: Extractor<HttpRequest>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<T> Freeze for Extractor<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for Extractor<T>

§

impl<T> !Send for Extractor<T>

§

impl<T> !Sync for Extractor<T>

§

impl<T> Unpin for Extractor<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Extractor<T>

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<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T