Context

Struct Context 

Source
pub struct Context(/* private fields */);
Expand description

The main application context, providing thread-safe access to request and response data.

This is a wrapper around ContextInner that uses an Arc<RwLock<>> to allow for shared, mutable access across asynchronous tasks.

Implementations§

Source§

impl Context

Implementation of methods for Context structure.

Source

pub async fn get_aborted(&self) -> bool

Checks if the context has been marked as aborted.

§Returns
  • bool - True if the context is aborted, otherwise false.
Source

pub async fn set_aborted(&self, aborted: bool) -> &Self

Sets the aborted flag for the context.

§Arguments
  • bool - The aborted state to set.
§Returns
  • &Self - Reference to self for method chaining.
Source

pub async fn aborted(&self) -> &Self

Marks the context as aborted.

§Returns
  • &Self - Reference to the modified context.
Source

pub async fn cancel_aborted(&self) -> &Self

Cancels the aborted state of the context.

§Returns
  • &Self - Reference to the modified context.
Source

pub async fn get_closed(&self) -> bool

Checks if the connection is marked as closed.

§Returns
  • bool - True if the connection is closed, otherwise false.
Source

pub async fn set_closed(&self, closed: bool) -> &Self

Sets the closed flag for the connection.

§Arguments
  • bool - The new value for the closed flag.
§Returns
  • &Self - Reference to the modified context.
Source

pub async fn closed(&self) -> &Self

Marks the connection as closed.

§Returns
  • &Self - Reference to the modified context.
Source

pub async fn cancel_closed(&self) -> &Self

Cancels the closed state of the connection.

§Returns
  • &Self - Reference to the modified context.
Source

pub async fn is_terminated(&self) -> bool

Checks if the connection has been terminated (aborted and closed).

§Returns
  • bool - True if the connection is both aborted and closed, otherwise false.
Source

pub async fn try_get_stream(&self) -> OptionArcRwLockStream

Retrieves the underlying network stream, if available.

§Returns
  • OptionArcRwLockStream - The thread-safe, shareable network stream if it exists.
Source

pub async fn try_get_socket_addr(&self) -> OptionSocketAddr

Retrieves the remote socket address of the connection.

§Returns
  • OptionSocketAddr - The socket address of the remote peer if available.
Source

pub async fn get_socket_addr(&self) -> SocketAddr

Retrieves the remote socket address or a default value if unavailable.

§Returns
  • SocketAddr - The socket address of the remote peer, or default if unavailable.
Source

pub async fn try_get_socket_addr_string(&self) -> OptionString

Retrieves the remote socket address as a string.

§Returns
  • OptionString - The string representation of the socket address if available.
Source

pub async fn get_socket_addr_string(&self) -> String

Retrieves the remote socket address as a string, or a default value if unavailable.

§Returns
  • String - The string representation of the socket address, or default if unavailable.
Source

pub async fn try_get_socket_host(&self) -> OptionSocketHost

Retrieves the IP address part of the remote socket address.

§Returns
  • OptionSocketHost - The IP address of the remote peer if available.
Source

pub async fn try_get_socket_port(&self) -> OptionSocketPort

Retrieves the port number part of the remote socket address.

§Returns
  • OptionSocketPort - The port number of the remote peer if available.
Source

pub async fn get_request(&self) -> Request

Retrieves the current HTTP request.

§Returns
  • Request - A clone of the current request.
Source

pub async fn with_request<F, Fut, R>(&self, func: F) -> R
where F: Fn(Request) -> Fut, Fut: FutureSendStatic<R>,

Executes an asynchronous closure with the current request.

This method provides temporary access to the request data without needing to clone it.

§Arguments
  • F - A closure that takes the Request and returns a future.
§Returns
  • R - The result of the provided closure’s future.
Source

pub async fn get_request_string(&self) -> String

Retrieves the string representation of the current request.

§Returns
  • String - The full request as a string.
Source

pub async fn get_request_version(&self) -> RequestVersion

Retrieves the HTTP version of the request.

§Returns
  • RequestVersion - The HTTP version of the request.
Source

pub async fn get_request_method(&self) -> RequestMethod

Retrieves the HTTP method of the request.

§Returns
  • RequestMethod - The HTTP method of the request.
Source

pub async fn get_request_host(&self) -> RequestHost

Retrieves the host from the request headers.

§Returns
  • RequestHost - The host part of the request’s URI.
Source

pub async fn get_request_path(&self) -> RequestPath

Retrieves the path of the request.

§Returns
  • RequestPath - The path part of the request’s URI.
Source

pub async fn get_request_querys(&self) -> RequestQuerys

Retrieves the query parameters of the request.

§Returns
  • RequestQuerys - A map containing the query parameters.
Source

pub async fn try_get_request_query<K>(&self, key: K) -> OptionRequestQuerysValue
where K: AsRef<str>,

Retrieves a specific query parameter by its key.

§Arguments
  • AsRef<str> - The query parameter key.
§Returns
  • OptionRequestQuerysValue - The query parameter value if exists.
Source

pub async fn get_request_body(&self) -> RequestBody

Retrieves the body of the request.

§Returns
  • RequestBody - A clone of the request’s body.
Source

pub async fn get_request_body_string(&self) -> String

Retrieves the request body as a string.

§Returns
  • String - The request body converted to a string.
Source

pub async fn get_request_body_json<J>(&self) -> ResultJsonError<J>

Deserializes the request body from JSON into a specified type.

§Returns
  • ResultJsonError<J> - The deserialized type J or a JSON error.
Source

pub async fn try_get_request_header<K>( &self, key: K, ) -> OptionRequestHeadersValue
where K: AsRef<str>,

Retrieves a specific request header by its key.

Gets a request header by key.

§Arguments
  • AsRef<str> - The header key.
§Returns
  • OptionRequestHeadersValue - The header values if exists.
Source

pub async fn get_request_headers(&self) -> RequestHeaders

Retrieves all request headers.

§Returns
  • RequestHeaders - A clone of the request’s header map.
Source

pub async fn try_get_request_header_front<K>( &self, key: K, ) -> OptionRequestHeadersValueItem
where K: AsRef<str>,

Retrieves the first value of a specific request header.

§Arguments
  • AsRef<str> - The key of the header.
§Returns
  • OptionRequestHeadersValueItem - The first value of the header if it exists.
Source

pub async fn try_get_request_header_back<K>( &self, key: K, ) -> OptionRequestHeadersValueItem
where K: AsRef<str>,

Retrieves the last value of a specific request header.

§Arguments
  • AsRef<str> - The key of the header.
§Returns
  • OptionRequestHeadersValueItem - The last value of the header if it exists.
Source

pub async fn get_request_header_len<K>(&self, key: K) -> usize
where K: AsRef<str>,

Retrieves the number of values for a specific request header.

§Arguments
  • AsRef<str> - The key of the header.
§Returns
  • usize - The number of values for the specified header.
Source

pub async fn get_request_headers_values_length(&self) -> usize

Retrieves the total number of values across all request headers.

§Returns
  • usize - The total count of all values in all headers.
Source

pub async fn get_request_headers_length(&self) -> usize

Retrieves the total number of request headers.

§Returns
  • usize - The total number of headers in the request.
Source

pub async fn get_request_has_header<K>(&self, key: K) -> bool
where K: AsRef<str>,

Checks if a specific request header exists.

§Arguments
  • AsRef<str> - The key of the header to check.
§Returns
  • bool - True if the header exists, otherwise false.
Source

pub async fn get_request_has_header_value<K, V>(&self, key: K, value: V) -> bool
where K: AsRef<str>, V: AsRef<str>,

Checks if a request header has a specific value.

§Arguments
  • AsRef<str> - The header key.
  • AsRef<str> - The value to check.
§Returns
  • bool - True if header contains the value.
Source

pub async fn get_request_cookies(&self) -> Cookies

Parses and retrieves all cookies from the request headers.

§Returns
  • Cookies - A map of cookies parsed from the request’s Cookie header.

Retrieves a specific cookie by its name from the request.

§Arguments
  • AsRef<str> - The cookie name.
§Returns
  • OptionCookiesValue - The cookie value if exists.
Source

pub async fn get_request_upgrade_type(&self) -> UpgradeType

Retrieves the upgrade type of the request.

§Returns
  • UpgradeType - Indicates if the request is for a WebSocket connection.
Source

pub async fn get_request_is_ws(&self) -> bool

Checks if the request is a WebSocket upgrade request.

§Returns
  • bool - True if this is a WebSocket upgrade request.
Source

pub async fn get_request_is_h2c(&self) -> bool

Checks if the request is an HTTP/2 cleartext (h2c) upgrade.

§Returns
  • bool - True if this is an h2c upgrade request.
Source

pub async fn get_request_is_tls(&self) -> bool

Checks if the request is a TLS upgrade.

§Returns
  • bool - True if this is a TLS upgrade request.
Source

pub async fn get_request_is_unknown_upgrade(&self) -> bool

Checks if the request has an unknown upgrade type.

§Returns
  • bool - True if the upgrade type is unknown.
Source

pub async fn get_request_is_http1_1_or_higher(&self) -> bool

Checks if the request HTTP version is HTTP/1.1 or higher.

§Returns
  • bool - True if the version is HTTP/1.1 or higher.
Source

pub async fn get_request_is_http0_9(&self) -> bool

Checks if the request HTTP version is HTTP/0.9.

§Returns
  • bool - True if the version is HTTP/0.9.
Source

pub async fn get_request_is_http1_0(&self) -> bool

Checks if the request HTTP version is HTTP/1.0.

§Returns
  • bool - True if the version is HTTP/1.0.
Source

pub async fn get_request_is_http1_1(&self) -> bool

Checks if the request HTTP version is HTTP/1.1.

§Returns
  • bool - True if the version is HTTP/1.1.
Source

pub async fn get_request_is_http2(&self) -> bool

Checks if the request HTTP version is HTTP/2.

§Returns
  • bool - True if the version is HTTP/2.
Source

pub async fn get_request_is_http3(&self) -> bool

Checks if the request HTTP version is HTTP/3.

§Returns
  • bool - True if the version is HTTP/3.
Source

pub async fn get_request_is_unknown_version(&self) -> bool

Checks if the request has an unknown HTTP version.

§Returns
  • bool - True if the version is unknown.
Source

pub async fn get_request_is_http(&self) -> bool

Checks if the request uses HTTP protocol.

§Returns
  • bool - True if the version belongs to HTTP family.
Source

pub async fn get_request_is_get(&self) -> bool

Checks if the request method is GET.

§Returns
  • bool - True if the method is GET.
Source

pub async fn get_request_is_post(&self) -> bool

Checks if the request method is POST.

§Returns
  • bool - True if the method is POST.
Source

pub async fn get_request_is_put(&self) -> bool

Checks if the request method is PUT.

§Returns
  • bool - True if the method is PUT.
Source

pub async fn get_request_is_delete(&self) -> bool

Checks if the request method is DELETE.

§Returns
  • bool - True if the method is DELETE.
Source

pub async fn get_request_is_patch(&self) -> bool

Checks if the request method is PATCH.

§Returns
  • bool - True if the method is PATCH.
Source

pub async fn get_request_is_head(&self) -> bool

Checks if the request method is HEAD.

§Returns
  • bool - True if the method is HEAD.
Source

pub async fn get_request_is_options(&self) -> bool

Checks if the request method is OPTIONS.

§Returns
  • bool - True if the method is OPTIONS.
Source

pub async fn get_request_is_connect(&self) -> bool

Checks if the request method is CONNECT.

§Returns
  • bool - True if the method is CONNECT.
Source

pub async fn get_request_is_trace(&self) -> bool

Checks if the request method is TRACE.

§Returns
  • bool - True if the method is TRACE.
Source

pub async fn get_request_is_unknown_method(&self) -> bool

Checks if the request method is unknown.

§Returns
  • bool - True if the method is unknown.
Source

pub async fn get_request_is_enable_keep_alive(&self) -> bool

Checks if the connection should be kept alive based on request headers.

§Returns
  • bool - True if the Connection header suggests keeping the connection alive, otherwise false.
Source

pub async fn get_request_is_disable_keep_alive(&self) -> bool

Checks if keep-alive should be disabled for the request.

§Returns
  • bool - True if keep-alive should be disabled.
Source

pub async fn get_response(&self) -> Response

Retrieves the current HTTP response.

§Returns
  • Response - A clone of the current response.
Source

pub async fn set_response<T>(&self, response: T) -> &Self
where T: Borrow<Response>,

Sets the HTTP response for the context.

§Arguments
  • Borrow<Response> - The response to set in the context.
§Returns
  • &Self - Reference to the modified context.
Source

pub async fn with_response<F, Fut, R>(&self, func: F) -> R
where F: Fn(Response) -> Fut, Fut: FutureSendStatic<R>,

Executes an asynchronous closure with the current response.

§Arguments
  • F - A closure that takes the Response and returns a future.
§Returns
  • R - The result of the provided closure’s future.
Source

pub async fn get_response_string(&self) -> String

Retrieves the string representation of the current response.

§Returns
  • String - The full response as a string.
Source

pub async fn get_response_version(&self) -> ResponseVersion

Retrieves the HTTP version of the response.

§Returns
  • ResponseVersion - The HTTP version of the response.
Source

pub async fn set_response_version(&self, version: ResponseVersion) -> &Self

Sets the HTTP version for the response.

§Arguments
  • ResponseVersion - The HTTP version to set for the response.
§Returns
  • &Self - Reference to the modified context.
Source

pub async fn get_response_headers(&self) -> ResponseHeaders

Retrieves all response headers.

§Returns
  • ResponseHeaders - A clone of the response’s header map.
Source

pub async fn try_get_response_header<K>( &self, key: K, ) -> OptionResponseHeadersValue
where K: AsRef<str>,

Retrieves a specific response header by its key.

§Arguments
  • AsRef<str> - The key of the header to retrieve.
§Returns
  • OptionResponseHeadersValue - The header values if the header exists.
Source

pub async fn set_response_header<K, V>(&self, key: K, value: V) -> &Self
where K: AsRef<str>, V: AsRef<str>,

Sets a response header with a new value, removing any existing values.

§Arguments
  • K - The key of the header to set.
  • V - The new value for the header.
§Returns
  • &Self - Reference to the modified context.
Source

pub async fn try_get_response_header_front<K>( &self, key: K, ) -> OptionResponseHeadersValueItem
where K: AsRef<str>,

Retrieves the first value of a specific response header.

§Arguments
  • AsRef<str> - The key of the header.
§Returns
  • OptionResponseHeadersValueItem - The first value of the header if it exists.
Source

pub async fn try_get_response_header_back<K>( &self, key: K, ) -> OptionResponseHeadersValueItem
where K: AsRef<str>,

Retrieves the last value of a specific response header.

§Arguments
  • AsRef<str> - The key of the header.
§Returns
  • OptionResponseHeadersValueItem - The last value of the header if it exists.
Source

pub async fn get_response_has_header<K>(&self, key: K) -> bool
where K: AsRef<str>,

Checks if a specific response header exists.

§Arguments
  • AsRef<str> - The key of the header to check.
§Returns
  • bool - True if the header exists, otherwise false.
Source

pub async fn get_response_header_value<K, V>(&self, key: K, value: V) -> bool
where K: AsRef<str>, V: AsRef<str>,

Checks if a response header has a specific value.

§Arguments
  • AsRef<str> - The key of the header.
  • AsRef<str> - The value to check for.
§Returns
  • bool - True if the header contains the specified value, otherwise false.
Source

pub async fn get_response_headers_length(&self) -> usize

Retrieves the total number of response headers.

§Returns
  • usize - The total number of headers in the response.
Source

pub async fn get_response_header_length<K>(&self, key: K) -> usize
where K: AsRef<str>,

Retrieves the number of values for a specific response header.

§Arguments
  • AsRef<str> - The key of the header.
§Returns
  • usize - The number of values for the specified header.
Source

pub async fn get_response_headers_values_length(&self) -> usize

Retrieves the total number of values across all response headers.

§Returns
  • usize - The total count of all values in all headers.
Source

pub async fn add_response_header<K, V>(&self, key: K, value: V) -> &Self
where K: AsRef<str>, V: AsRef<str>,

Adds a response header, adding it if it doesn’t exist or appending to it if it does.

§Arguments
  • AsRef<str> - The header key.
  • AsRef<str> - The header value.
§Returns
  • &Self - Reference to self for method chaining.
Source

pub async fn remove_response_header<K>(&self, key: K) -> &Self
where K: AsRef<str>,

Removes a response header and all its values.

§Arguments
  • AsRef<str> - The key of the header to remove.
§Returns
  • &Self - Reference to the modified context.
Source

pub async fn remove_response_header_value<K, V>( &self, key: K, value: V, ) -> &Self
where K: AsRef<str>, V: AsRef<str>,

Removes a specific value from a response header.

§Arguments
  • AsRef<str> - The header key.
  • AsRef<str> - The value to remove.
§Returns
  • &Self - Reference to self for method chaining.
Source

pub async fn clear_response_headers(&self) -> &Self

Clears all headers from the response.

§Returns
  • &Self - Reference to the modified context.
Source

pub async fn get_response_cookies(&self) -> Cookies

Parses and retrieves all cookies from the response headers.

§Returns
  • Cookies - A map of cookies parsed from the response’s Cookie header.

Retrieves a specific cookie by its name from the response.

§Arguments
  • AsRef<str> - The name of the cookie to retrieve.
§Returns
  • OptionCookiesValue - The cookie’s value if it exists.
Source

pub async fn get_response_body(&self) -> ResponseBody

Retrieves the body of the response.

§Returns
  • ResponseBody - A clone of the response’s body.
Source

pub async fn set_response_body<B>(&self, body: B) -> &Self
where B: AsRef<[u8]>,

Sets the body of the response.

§Arguments
  • B - The body to set for the response.
§Returns
  • &Self - Reference to the modified context.
Source

pub async fn get_response_body_string(&self) -> String

Retrieves the response body as a string.

§Returns
  • String - The response body converted to a string.
Source

pub async fn get_response_body_json<J>(&self) -> ResultJsonError<J>

Deserializes the response body from JSON into a specified type.

§Returns
  • ResultJsonError<J> - The deserialized type J or a JSON error.
Source

pub async fn get_response_reason_phrase(&self) -> ResponseReasonPhrase

Retrieves the reason phrase of the response’s status code.

§Returns
  • ResponseReasonPhrase - The reason phrase associated with the response’s status code.
Source

pub async fn set_response_reason_phrase<P>(&self, reason_phrase: P) -> &Self
where P: AsRef<str>,

Sets the reason phrase for the response’s status code.

§Arguments
  • AsRef<str> - The reason phrase to set.
§Returns
  • &Self - Reference to the modified context.
Source

pub async fn get_response_status_code(&self) -> ResponseStatusCode

Retrieves the status code of the response.

§Returns

The status code of the response.

Source

pub async fn set_response_status_code( &self, status_code: ResponseStatusCode, ) -> &Self

Sets the status code for the response.

§Arguments
  • ResponseStatusCode - The status code to set for the response.
§Returns
  • &Self - A reference to the modified context.
Source

pub async fn get_route_params(&self) -> RouteParams

Retrieves the parameters extracted from the route path.

§Returns
  • RouteParams - A map containing the route parameters.
Source

pub async fn try_get_route_param<T>(&self, name: T) -> OptionString
where T: AsRef<str>,

Retrieves a specific route parameter by its name.

§Arguments
  • AsRef<str> - The name of the route parameter to retrieve.
§Returns
  • OptionString - The value of the route parameter if it exists.
Source

pub async fn get_attributes(&self) -> HashMapArcAnySendSync

Retrieves all attributes stored in the context.

§Returns
  • HashMapArcAnySendSync - A map containing all attributes.
Source

pub async fn try_get_attribute<K, V>(&self, key: K) -> Option<V>
where K: AsRef<str>, V: AnySendSyncClone,

Retrieves a specific attribute by its key, casting it to the specified type.

§Arguments
  • AsRef<str> - The key of the attribute to retrieve.
§Returns
  • Option<V> - The attribute’s value if it exists and can be cast to the specified type.
Source

pub async fn set_attribute<K, V>(&self, key: K, value: V) -> &Self
where K: AsRef<str>, V: AnySendSyncClone,

Sets an attribute in the context.

§Arguments
  • AsRef<str> - The key of the attribute to set.
  • AnySendSyncClone - The value of the attribute.
§Returns
  • &Self - A reference to the modified context.
Source

pub async fn remove_attribute<K>(&self, key: K) -> &Self
where K: AsRef<str>,

Removes an attribute from the context.

§Arguments
  • AsRef<str> - The key of the attribute to remove.
§Returns
  • &Self - A reference to the modified context.
Source

pub async fn clear_attribute(&self) -> &Self

Clears all attributes from the context.

§Returns
  • &Self - A reference to the modified context.
Source

pub async fn try_get_panic(&self) -> OptionPanic

Retrieves panic information if a panic has occurred during handling.

§Returns
  • OptionPanic - The panic information if a panic was caught.
Source

pub async fn set_hook<K, F, Fut>(&self, key: K, hook: F) -> &Self

Sets a hook function for the context with a custom key.

§Arguments
  • ToString - The key to identify this hook.
  • FnContextSendSyncStatic<Fut, ()>, Fut: FutureSendStatic<()> - The hook function to store.
§Returns
  • &Self - A reference to the modified context.
Source

pub async fn try_get_hook<K>( &self, key: K, ) -> OptionArcFnContextPinBoxSendSync<()>
where K: ToString,

Retrieves a hook function if it has been set.

§Arguments
  • K: ToString - The key to identify the hook.
§Returns
  • OptionArcFnContextPinBoxSendSync<()> - The hook function if it has been set.
Source

pub async fn send(&self) -> ResponseResult

Sends the response headers and body to the client.

§Returns
  • ResponseResult - The outcome of the send operation.
Source

pub async fn send_once(&self) -> ResponseResult

Sends the response and then closes the connection.

After sending, the connection will be marked as closed.

§Returns
  • ResponseResult - The outcome of the send operation.
Source

pub async fn send_body(&self) -> ResponseResult

Sends only the response body to the client.

This is useful for streaming data or for responses where headers have already been sent.

§Returns
  • ResponseResult - The outcome of the send operation.
Source

pub async fn send_body_once(&self) -> ResponseResult

Sends only the response body and then closes the connection.

After sending the body, the connection will be marked as closed.

§Returns
  • ResponseResult - The outcome of the send operation.
Source

pub async fn send_with_data<D>(&self, data: D) -> ResponseResult
where D: AsRef<[u8]>,

Sends the response headers and body to the client with additional data.

§Arguments
  • AsRef<[u8]> - The additional data to send.
§Returns
  • ResponseResult - The outcome of the send operation.
Source

pub async fn send_once_with_data<D>(&self, data: D) -> ResponseResult
where D: AsRef<[u8]>,

Sends the response and then closes the connection with additional data.

After sending, the connection will be marked as closed.

§Arguments
  • AsRef<[u8]> - The additional data to send.
§Returns
  • ResponseResult - The outcome of the send operation.
Source

pub async fn send_body_with_data<D>(&self, data: D) -> ResponseResult
where D: AsRef<[u8]>,

Sends only the response body to the client with additional data.

This is useful for streaming data or for responses where headers have already been sent.

§Arguments
  • AsRef<[u8]> - The additional data to send as the body.
§Returns
  • ResponseResult - The outcome of the send operation.
Source

pub async fn send_body_once_with_data<D>(&self, data: D) -> ResponseResult
where D: AsRef<[u8]>,

Sends only the response body and then closes the connection with additional data.

After sending the body, the connection will be marked as closed.

§Arguments
  • AsRef<[u8]> - The additional data to send as the body.
§Returns
  • ResponseResult - The outcome of the send operation.
Source

pub async fn send_body_list_with_data<I, D>( &self, data_iter: I, ) -> ResponseResult
where I: IntoIterator<Item = D>, D: AsRef<[u8]>,

Sends a list of response bodies to the client with additional data.

This is useful for streaming multiple data chunks or for responses where headers have already been sent.

§Arguments
  • I: IntoIterator<Item = D>, D: AsRef<[u8]> - The additional data to send as a list of bodies.
§Returns
  • ResponseResult - The outcome of the send operation.
Source

pub async fn send_body_list_once_with_data<I, D>( &self, data_iter: I, ) -> ResponseResult
where I: IntoIterator<Item = D>, D: AsRef<[u8]>,

Sends a list of response bodies and then closes the connection with additional data.

After sending the body list, the connection will be marked as closed.

§Arguments
  • I: IntoIterator<Item = D>, D: AsRef<[u8]> - The additional data to send as a list of bodies.
§Returns
  • ResponseResult - The outcome of the send operation.
Source

pub async fn flush(&self) -> ResponseResult

Flushes the underlying network stream, ensuring all buffered data is sent.

§Returns
  • ResponseResult - The outcome of the flush operation.
Source

pub async fn http_from_stream(&self, buffer: usize) -> RequestReaderHandleResult

Reads an HTTP request from the underlying stream.

§Arguments
  • usize - The read buffer size.
§Returns
  • RequestReaderHandleResult - The parsed request or error.
Source

pub async fn ws_from_stream(&self, buffer: usize) -> RequestReaderHandleResult

Reads a WebSocket frame from the underlying stream.

§Arguments
  • usize - The read buffer size.
§Returns
  • RequestReaderHandleResult - The parsed frame or error.

Trait Implementations§

Source§

impl Clone for Context

Source§

fn clone(&self) -> Context

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Context

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Context

Source§

fn default() -> Context

Returns the “default value” for a type. Read more
Source§

impl Display for Context

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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> AnySend for T
where T: Any + Send,

Source§

impl<T> AnySendClone for T
where T: Any + Send + Clone,

Source§

impl<T> AnySendSync for T
where T: Any + Send + Sync,

Source§

impl<T> AnySendSyncClone for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> AnySync for T
where T: Any + Sync,

Source§

impl<T> AnySyncClone for T
where T: Any + Sync + Clone,

Source§

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