Fix more small things

This commit is contained in:
Matthew Pomes 2024-11-22 14:10:42 -06:00
parent 10b9faa30a
commit b3806e66ad
No known key found for this signature in database
GPG Key ID: B8C0D93B8D8FBDB7
5 changed files with 14 additions and 11 deletions

View File

@ -114,7 +114,7 @@ impl<'r> Data<'r> {
/// use rocket::data::{Data, FromData, Outcome}; /// use rocket::data::{Data, FromData, Outcome};
/// use rocket::http::Status; /// use rocket::http::Status;
/// # struct MyType; /// # struct MyType;
/// # #[derive(rocket::TypedError)] /// # #[derive(rocket::TypedError, Debug)]
/// # struct MyError; /// # struct MyError;
/// ///
/// #[rocket::async_trait] /// #[rocket::async_trait]

View File

@ -1,3 +1,5 @@
use std::fmt;
use crate::catcher::TypedError; use crate::catcher::TypedError;
use crate::http::RawStr; use crate::http::RawStr;
use crate::request::{Request, local_cache}; use crate::request::{Request, local_cache};
@ -182,7 +184,7 @@ pub type Outcome<'r, T, E = <T as FromData<'r>>::Error>
/// use rocket::request::Request; /// use rocket::request::Request;
/// use rocket::data::{self, Data, FromData}; /// use rocket::data::{self, Data, FromData};
/// # struct MyType; /// # struct MyType;
/// # #[derive(rocket::TypedError)] /// # #[derive(rocket::TypedError, Debug)]
/// # struct MyError; /// # struct MyError;
/// ///
/// #[rocket::async_trait] /// #[rocket::async_trait]
@ -312,7 +314,7 @@ pub type Outcome<'r, T, E = <T as FromData<'r>>::Error>
#[crate::async_trait] #[crate::async_trait]
pub trait FromData<'r>: Sized { pub trait FromData<'r>: Sized {
/// The associated error to be returned when the guard fails. /// 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` /// Asynchronously validates, parses, and converts an instance of `Self`
/// from the incoming request body data. /// from the incoming request body data.

View File

@ -160,7 +160,7 @@ use crate::http::{uri::{Segments, error::PathError, fmt::Path}, Status};
/// use rocket::TypedError; /// use rocket::TypedError;
/// # #[allow(dead_code)] /// # #[allow(dead_code)]
/// # struct MyParam<'r> { key: &'r str, value: usize } /// # struct MyParam<'r> { key: &'r str, value: usize }
/// #[derive(TypedError)] /// #[derive(TypedError, Debug)]
/// struct MyParamError<'a>(&'a str); /// struct MyParamError<'a>(&'a str);
/// ///
/// impl<'r> FromParam<'r> for MyParam<'r> { /// impl<'r> FromParam<'r> for MyParam<'r> {
@ -192,7 +192,7 @@ use crate::http::{uri::{Segments, error::PathError, fmt::Path}, Status};
/// # #[macro_use] extern crate rocket; /// # #[macro_use] extern crate rocket;
/// # use rocket::request::FromParam; /// # use rocket::request::FromParam;
/// # use rocket::TypedError; /// # use rocket::TypedError;
/// # #[derive(TypedError)] /// # #[derive(TypedError, Debug)]
/// # struct MyParamError<'a>(&'a str); /// # struct MyParamError<'a>(&'a str);
/// # #[allow(dead_code)] /// # #[allow(dead_code)]
/// # struct MyParam<'r> { key: &'r str, value: usize } /// # struct MyParam<'r> { key: &'r str, value: usize }
@ -215,7 +215,7 @@ use crate::http::{uri::{Segments, error::PathError, fmt::Path}, Status};
/// ``` /// ```
pub trait FromParam<'a>: Sized { pub trait FromParam<'a>: Sized {
/// The associated error to be returned if parsing/validation fails. /// 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 /// Parses and validates an instance of `Self` from a path parameter string
/// or returns an `Error` if parsing or validation fails. /// or returns an `Error` if parsing or validation fails.
@ -397,7 +397,7 @@ impl<'a, T: FromParam<'a>> FromParam<'a> for Option<T> {
/// the `Utf8Error`. /// the `Utf8Error`.
pub trait FromSegments<'r>: Sized { pub trait FromSegments<'r>: Sized {
/// The associated error to be returned when parsing fails. /// 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 /// Parses an instance of `Self` from many dynamic path parameter strings or
/// returns an `Error` if one cannot be parsed. /// returns an `Error` if one cannot be parsed.

View File

@ -1,4 +1,5 @@
use std::convert::Infallible; use std::convert::Infallible;
use std::fmt;
use std::net::{IpAddr, SocketAddr}; use std::net::{IpAddr, SocketAddr};
use crate::catcher::TypedError; use crate::catcher::TypedError;
@ -36,7 +37,7 @@ pub type Outcome<S, E> = outcome::Outcome<S, E, E>;
/// use rocket::request::{self, Request, FromRequest}; /// use rocket::request::{self, Request, FromRequest};
/// # struct MyType; /// # struct MyType;
/// # use rocket::TypedError; /// # use rocket::TypedError;
/// # #[derive(TypedError)] /// # #[derive(TypedError, Debug)]
/// # struct MyError; /// # struct MyError;
/// ///
/// #[rocket::async_trait] /// #[rocket::async_trait]
@ -408,7 +409,7 @@ pub type Outcome<S, E> = outcome::Outcome<S, E, E>;
#[crate::async_trait] #[crate::async_trait]
pub trait FromRequest<'r>: Sized { pub trait FromRequest<'r>: Sized {
/// The associated error to be returned if derivation fails. /// 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. /// Derives an instance of `Self` from the incoming request metadata.
/// ///

View File

@ -367,7 +367,7 @@ use rocket::tokio::fs::File;
# pub fn new(size: usize) -> PasteId<'static> { todo!() } # pub fn new(size: usize) -> PasteId<'static> { todo!() }
# pub fn file_path(&self) -> PathBuf { todo!() } # pub fn file_path(&self) -> PathBuf { todo!() }
# } # }
# #[derive(rocket::TypedError)] # #[derive(Debug, rocket::TypedError)]
# pub struct InvalidPasteId; # pub struct InvalidPasteId;
# impl<'a> FromParam<'a> for PasteId<'a> { # impl<'a> FromParam<'a> for PasteId<'a> {
# type Error = InvalidPasteId; # type Error = InvalidPasteId;
@ -446,7 +446,7 @@ pub struct PasteId<'a>(Cow<'a, str>);
# pub fn file_path(&self) -> PathBuf { todo!() } # pub fn file_path(&self) -> PathBuf { todo!() }
# } # }
# #
# #[derive(rocket::TypedError)] # #[derive(Debug, rocket::TypedError)]
# pub struct InvalidPasteId; # pub struct InvalidPasteId;
# impl<'a> FromParam<'a> for PasteId<'a> { # impl<'a> FromParam<'a> for PasteId<'a> {
# type Error = InvalidPasteId; # type Error = InvalidPasteId;