Skip to content

Commit

Permalink
Fix more small things
Browse files Browse the repository at this point in the history
  • Loading branch information
the10thWiz committed Nov 22, 2024
1 parent 10b9faa commit b3806e6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/lib/src/data/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<'r> Data<'r> {
/// use rocket::data::{Data, FromData, Outcome};
/// use rocket::http::Status;
/// # struct MyType;
/// # #[derive(rocket::TypedError)]
/// # #[derive(rocket::TypedError, Debug)]
/// # struct MyError;
///
/// #[rocket::async_trait]
Expand Down
6 changes: 4 additions & 2 deletions core/lib/src/data/from_data.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt;

use crate::catcher::TypedError;
use crate::http::RawStr;
use crate::request::{Request, local_cache};
Expand Down Expand Up @@ -182,7 +184,7 @@ pub type Outcome<'r, T, E = <T as FromData<'r>>::Error>
/// use rocket::request::Request;
/// use rocket::data::{self, Data, FromData};
/// # struct MyType;
/// # #[derive(rocket::TypedError)]
/// # #[derive(rocket::TypedError, Debug)]
/// # struct MyError;
///
/// #[rocket::async_trait]
Expand Down Expand Up @@ -312,7 +314,7 @@ pub type Outcome<'r, T, E = <T as FromData<'r>>::Error>
#[crate::async_trait]
pub trait FromData<'r>: Sized {
/// The associated error to be returned when the guard fails.
type Error: TypedError<'r> + 'r;
type Error: TypedError<'r> + fmt::Debug + 'r;

/// Asynchronously validates, parses, and converts an instance of `Self`
/// from the incoming request body data.
Expand Down
8 changes: 4 additions & 4 deletions core/lib/src/request/from_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ use crate::http::{uri::{Segments, error::PathError, fmt::Path}, Status};
/// use rocket::TypedError;
/// # #[allow(dead_code)]
/// # struct MyParam<'r> { key: &'r str, value: usize }
/// #[derive(TypedError)]
/// #[derive(TypedError, Debug)]
/// struct MyParamError<'a>(&'a str);
///
/// impl<'r> FromParam<'r> for MyParam<'r> {
Expand Down Expand Up @@ -192,7 +192,7 @@ use crate::http::{uri::{Segments, error::PathError, fmt::Path}, Status};
/// # #[macro_use] extern crate rocket;
/// # use rocket::request::FromParam;
/// # use rocket::TypedError;
/// # #[derive(TypedError)]
/// # #[derive(TypedError, Debug)]
/// # struct MyParamError<'a>(&'a str);
/// # #[allow(dead_code)]
/// # struct MyParam<'r> { key: &'r str, value: usize }
Expand All @@ -215,7 +215,7 @@ use crate::http::{uri::{Segments, error::PathError, fmt::Path}, Status};
/// ```
pub trait FromParam<'a>: Sized {
/// The associated error to be returned if parsing/validation fails.
type Error: TypedError<'a>;
type Error: TypedError<'a> + fmt::Debug + 'a;

/// Parses and validates an instance of `Self` from a path parameter string
/// or returns an `Error` if parsing or validation fails.
Expand Down Expand Up @@ -397,7 +397,7 @@ impl<'a, T: FromParam<'a>> FromParam<'a> for Option<T> {
/// the `Utf8Error`.
pub trait FromSegments<'r>: Sized {
/// The associated error to be returned when parsing fails.
type Error: TypedError<'r>;
type Error: TypedError<'r> + fmt::Debug + 'r;

/// Parses an instance of `Self` from many dynamic path parameter strings or
/// returns an `Error` if one cannot be parsed.
Expand Down
5 changes: 3 additions & 2 deletions core/lib/src/request/from_request.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::convert::Infallible;
use std::fmt;
use std::net::{IpAddr, SocketAddr};

use crate::catcher::TypedError;
Expand Down Expand Up @@ -36,7 +37,7 @@ pub type Outcome<S, E> = outcome::Outcome<S, E, E>;
/// use rocket::request::{self, Request, FromRequest};
/// # struct MyType;
/// # use rocket::TypedError;
/// # #[derive(TypedError)]
/// # #[derive(TypedError, Debug)]
/// # struct MyError;
///
/// #[rocket::async_trait]
Expand Down Expand Up @@ -408,7 +409,7 @@ pub type Outcome<S, E> = outcome::Outcome<S, E, E>;
#[crate::async_trait]
pub trait FromRequest<'r>: Sized {
/// The associated error to be returned if derivation fails.
type Error: TypedError<'r> + 'r;
type Error: TypedError<'r> + fmt::Debug + 'r;

/// Derives an instance of `Self` from the incoming request metadata.
///
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/12-pastebin.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ use rocket::tokio::fs::File;
# pub fn new(size: usize) -> PasteId<'static> { todo!() }
# pub fn file_path(&self) -> PathBuf { todo!() }
# }
# #[derive(rocket::TypedError)]
# #[derive(Debug, rocket::TypedError)]
# pub struct InvalidPasteId;
# impl<'a> FromParam<'a> for PasteId<'a> {
# type Error = InvalidPasteId;
Expand Down Expand Up @@ -446,7 +446,7 @@ pub struct PasteId<'a>(Cow<'a, str>);
# pub fn file_path(&self) -> PathBuf { todo!() }
# }
#
# #[derive(rocket::TypedError)]
# #[derive(Debug, rocket::TypedError)]
# pub struct InvalidPasteId;
# impl<'a> FromParam<'a> for PasteId<'a> {
# type Error = InvalidPasteId;
Expand Down

0 comments on commit b3806e6

Please sign in to comment.