mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-04-19 22:44:38 +00:00
require all resource results to be sendable
This commit is contained in:
parent
06e6c93a46
commit
d7282786b1
3 changed files with 20 additions and 11 deletions
|
@ -419,7 +419,7 @@ macro_rules! implOpenapiRouter {
|
|||
|
||||
fn create<Handler : ResourceCreate>(&mut self)
|
||||
where
|
||||
Handler::Res : Send + 'static,
|
||||
Handler::Res : 'static,
|
||||
Handler::Body : 'static
|
||||
{
|
||||
let schema = (self.0).1.add_schema::<Handler::Res>();
|
||||
|
@ -435,7 +435,7 @@ macro_rules! implOpenapiRouter {
|
|||
|
||||
fn update_all<Handler : ResourceUpdateAll>(&mut self)
|
||||
where
|
||||
Handler::Res : Send + 'static,
|
||||
Handler::Res : 'static,
|
||||
Handler::Body : 'static
|
||||
{
|
||||
let schema = (self.0).1.add_schema::<Handler::Res>();
|
||||
|
@ -451,7 +451,7 @@ macro_rules! implOpenapiRouter {
|
|||
|
||||
fn update<Handler : ResourceUpdate>(&mut self)
|
||||
where
|
||||
Handler::Res : Send + 'static,
|
||||
Handler::Res : 'static,
|
||||
Handler::Body : 'static
|
||||
{
|
||||
let schema = (self.0).1.add_schema::<Handler::Res>();
|
||||
|
|
|
@ -80,7 +80,7 @@ impl Response
|
|||
|
||||
|
||||
/// A trait provided to convert a resource's result to json.
|
||||
pub trait ResourceResult
|
||||
pub trait ResourceResult : Send
|
||||
{
|
||||
type Err : Error + Send + 'static;
|
||||
|
||||
|
@ -151,6 +151,8 @@ fn errorlog<E : std::fmt::Display>(e : E)
|
|||
fn errorlog<E>(_e : E) {}
|
||||
|
||||
impl<R : ResponseBody, E : Error> ResourceResult for Result<R, E>
|
||||
where
|
||||
Self : Send
|
||||
{
|
||||
type Err = SerdeJsonError;
|
||||
|
||||
|
@ -267,6 +269,8 @@ impl<T : Debug> Debug for Success<T>
|
|||
}
|
||||
|
||||
impl<T : ResponseBody> ResourceResult for Success<T>
|
||||
where
|
||||
Self : Send
|
||||
{
|
||||
type Err = SerdeJsonError;
|
||||
|
||||
|
@ -460,6 +464,8 @@ impl ResourceResult for NoContent
|
|||
}
|
||||
|
||||
impl<E : Error> ResourceResult for Result<NoContent, E>
|
||||
where
|
||||
Self : Send
|
||||
{
|
||||
type Err = SerdeJsonError;
|
||||
|
||||
|
@ -520,6 +526,8 @@ impl<T : Debug> Debug for Raw<T>
|
|||
}
|
||||
|
||||
impl<T : Into<Body>> ResourceResult for Raw<T>
|
||||
where
|
||||
Self : Send
|
||||
{
|
||||
type Err = SerdeJsonError; // just for easier handling of `Result<Raw<T>, E>`
|
||||
|
||||
|
@ -545,6 +553,7 @@ impl<T : Into<Body>> ResourceResult for Raw<T>
|
|||
|
||||
impl<T, E : Error> ResourceResult for Result<Raw<T>, E>
|
||||
where
|
||||
Self : Send,
|
||||
Raw<T> : ResourceResult<Err = SerdeJsonError>
|
||||
{
|
||||
type Err = SerdeJsonError;
|
||||
|
|
|
@ -73,17 +73,17 @@ pub trait DrawResourceRoutes
|
|||
|
||||
fn create<Handler : ResourceCreate>(&mut self)
|
||||
where
|
||||
Handler::Res : Send + 'static,
|
||||
Handler::Res : 'static,
|
||||
Handler::Body : 'static;
|
||||
|
||||
fn update_all<Handler : ResourceUpdateAll>(&mut self)
|
||||
where
|
||||
Handler::Res : Send + 'static,
|
||||
Handler::Res : 'static,
|
||||
Handler::Body : 'static;
|
||||
|
||||
fn update<Handler : ResourceUpdate>(&mut self)
|
||||
where
|
||||
Handler::Res : Send + 'static,
|
||||
Handler::Res : 'static,
|
||||
Handler::Body : 'static;
|
||||
|
||||
fn delete_all<Handler : ResourceDeleteAll>(&mut self);
|
||||
|
@ -175,7 +175,7 @@ fn handle_with_body<B, F, R>(state : State, get_result : F) -> Pin<Box<HandlerFu
|
|||
where
|
||||
B : RequestBody + 'static,
|
||||
F : FnOnce(&mut State, B) -> R + Send + 'static,
|
||||
R : ResourceResult + Send + 'static
|
||||
R : ResourceResult + 'static
|
||||
{
|
||||
body_to_res(state, get_result)
|
||||
.then(|(state, res)| match res {
|
||||
|
@ -207,7 +207,7 @@ fn search_handler<Handler : ResourceSearch>(mut state : State) -> Pin<Box<Handle
|
|||
|
||||
fn create_handler<Handler : ResourceCreate>(state : State) -> Pin<Box<HandlerFuture>>
|
||||
where
|
||||
Handler::Res : Send + 'static,
|
||||
Handler::Res : 'static,
|
||||
Handler::Body : 'static
|
||||
{
|
||||
handle_with_body::<Handler::Body, _, _>(state, |state, body| Handler::create(state, body))
|
||||
|
@ -215,7 +215,7 @@ where
|
|||
|
||||
fn update_all_handler<Handler : ResourceUpdateAll>(state : State) -> Pin<Box<HandlerFuture>>
|
||||
where
|
||||
Handler::Res : Send + 'static,
|
||||
Handler::Res : 'static,
|
||||
Handler::Body : 'static
|
||||
{
|
||||
handle_with_body::<Handler::Body, _, _>(state, |state, body| Handler::update_all(state, body))
|
||||
|
@ -223,7 +223,7 @@ where
|
|||
|
||||
fn update_handler<Handler : ResourceUpdate>(state : State) -> Pin<Box<HandlerFuture>>
|
||||
where
|
||||
Handler::Res : Send + 'static,
|
||||
Handler::Res : 'static,
|
||||
Handler::Body : 'static
|
||||
{
|
||||
let id = {
|
||||
|
|
Loading…
Add table
Reference in a new issue