mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-02-22 20:52:27 +00:00
remove FromBodyNoError and replace with std::convert::Infallible
This commit is contained in:
parent
4cd2474d90
commit
52679ad29d
3 changed files with 7 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
|||
use super::{IntoResponseError, ResourceResult, handle_error};
|
||||
use crate::{FromBody, FromBodyNoError, RequestBody, ResourceType, Response, StatusCode};
|
||||
use crate::{FromBody, RequestBody, ResourceType, Response, StatusCode};
|
||||
#[cfg(feature = "openapi")]
|
||||
use crate::OpenapiSchema;
|
||||
use futures_core::future::Future;
|
||||
|
@ -10,6 +10,7 @@ use mime::Mime;
|
|||
use openapiv3::{SchemaKind, StringFormat, StringType, Type, VariantOrUnknownOrEmpty};
|
||||
use serde_json::error::Error as SerdeJsonError;
|
||||
use std::{
|
||||
convert::Infallible,
|
||||
fmt::Display,
|
||||
pin::Pin
|
||||
};
|
||||
|
@ -89,7 +90,7 @@ impl<T : Clone> Clone for Raw<T>
|
|||
|
||||
impl<T : for<'a> From<&'a [u8]>> FromBody for Raw<T>
|
||||
{
|
||||
type Err = FromBodyNoError;
|
||||
type Err = Infallible;
|
||||
|
||||
fn from_body(body : Bytes, mime : Mime) -> Result<Self, Self::Err>
|
||||
{
|
||||
|
|
|
@ -8,7 +8,6 @@ use std::{
|
|||
error::Error,
|
||||
panic::RefUnwindSafe
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
#[cfg(not(feature = "openapi"))]
|
||||
pub trait ResourceType
|
||||
|
@ -68,8 +67,8 @@ struct RawImage {
|
|||
pub trait FromBody : Sized
|
||||
{
|
||||
/// The error type returned by the conversion if it was unsuccessfull. When using the derive
|
||||
/// macro, there is no way to trigger an error, so
|
||||
/// [`FromBodyNoError`](struct.FromBodyNoError.html) is used here.
|
||||
/// macro, there is no way to trigger an error, so `Infallible` is used here. However, this
|
||||
/// might change in the future.
|
||||
type Err : Error;
|
||||
|
||||
/// Perform the conversion.
|
||||
|
@ -86,12 +85,6 @@ impl<T : DeserializeOwned> FromBody for T
|
|||
}
|
||||
}
|
||||
|
||||
/// This error type can be used by [`FromBody`](trait.FromBody.html) implementations when there
|
||||
/// is no need to return any errors.
|
||||
#[derive(Clone, Copy, Debug, Error)]
|
||||
#[error("No Error")]
|
||||
pub struct FromBodyNoError;
|
||||
|
||||
|
||||
/**
|
||||
A type that can be used inside a request body. Implemented for every type that is deserializable
|
||||
|
|
|
@ -120,9 +120,9 @@ pub fn expand_from_body(input : DeriveInput) -> Result<TokenStream>
|
|||
impl #generics #krate::FromBody for #ident #generics
|
||||
where #where_clause
|
||||
{
|
||||
type Err = #krate::FromBodyNoError;
|
||||
type Err = ::std::convert::Infallible;
|
||||
|
||||
fn from_body(#body_ident : #krate::gotham::hyper::body::Bytes, #type_ident : #krate::Mime) -> Result<Self, #krate::FromBodyNoError>
|
||||
fn from_body(#body_ident : #krate::gotham::hyper::body::Bytes, #type_ident : #krate::Mime) -> Result<Self, ::std::convert::Infallible>
|
||||
{
|
||||
#block
|
||||
Ok(#ctor)
|
||||
|
|
Loading…
Add table
Reference in a new issue