Trait mendes::application::Application
source · [−]pub trait Application: Send + Sized {
type RequestBody: Send;
type ResponseBody: Send;
type Error: IntoResponse<Self> + WithStatus + From<Error> + Send;
fn handle<'async_trait>(
cx: Context<Self>
) -> Pin<Box<dyn Future<Output = Response<Self::ResponseBody>> + Send + 'async_trait>>
where
Self: 'async_trait;
fn from_query<'a, T: Deserialize<'a>>(
req: &'a Parts
) -> Result<T, Self::Error> { ... }
fn from_body_bytes<'de, T: Deserialize<'de>>(
req: &Parts,
bytes: &'de [u8]
) -> Result<T, Error> { ... }
fn from_body<'life0, 'async_trait, T: DeserializeOwned>(
req: &'life0 Parts,
body: Self::RequestBody
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>
where
Self::RequestBody: HttpBody + Send,
<Self::RequestBody as HttpBody>::Data: Send,
<Self::RequestBody as HttpBody>::Error: Into<Box<dyn StdError + Sync + Send>>,
T: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
{ ... }
fn body_bytes<'async_trait, B>(
body: B
) -> Pin<Box<dyn Future<Output = Result<Bytes, B::Error>> + Send + 'async_trait>>
where
B: HttpBody + Send,
<B as HttpBody>::Data: Send,
B: 'async_trait,
{ ... }
fn redirect(status: StatusCode, path: &str) -> Response<Self::ResponseBody>
where
Self::ResponseBody: Default,
{ ... }
}
This is supported on crate feature
application
only.Expand description
Main interface for an application or service
The Application
holds state and routes request to the proper handlers. A handler gets
an immutable reference to the Application
to access application state. Common usage
for this would be to hold a persistent storage connection pool.
The Application
also helps process handler reponses. It can handle errors and turn them
into HTTP responses, using the error()
method to transform the Error
associated type
into a Response
.
Associated Types
type RequestBody: Send
type ResponseBody: Send
type Error: IntoResponse<Self> + WithStatus + From<Error> + Send
Required methods
Provided methods
fn from_query<'a, T: Deserialize<'a>>(req: &'a Parts) -> Result<T, Self::Error>
fn from_body_bytes<'de, T: Deserialize<'de>>(
req: &Parts,
bytes: &'de [u8]
) -> Result<T, Error>
fn from_body<'life0, 'async_trait, T: DeserializeOwned>(
req: &'life0 Parts,
body: Self::RequestBody
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>> where
Self::RequestBody: HttpBody + Send,
<Self::RequestBody as HttpBody>::Data: Send,
<Self::RequestBody as HttpBody>::Error: Into<Box<dyn StdError + Sync + Send>>,
T: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn from_body<'life0, 'async_trait, T: DeserializeOwned>(
req: &'life0 Parts,
body: Self::RequestBody
) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>> where
Self::RequestBody: HttpBody + Send,
<Self::RequestBody as HttpBody>::Data: Send,
<Self::RequestBody as HttpBody>::Error: Into<Box<dyn StdError + Sync + Send>>,
T: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
This is supported on crate feature
with-http-body
only.This is supported on crate feature
with-http-body
only.