Use 'dep' syntax for 'http' features.

This commit is contained in:
Sergio Benitez 2024-04-26 01:42:33 -07:00
parent 84072a813a
commit e6aaea072c
12 changed files with 46 additions and 49 deletions

View File

@ -17,8 +17,8 @@ rust-version = "1.75"
[features] [features]
default = [] default = []
serde = ["uncased/with-serde-alloc", "serde_"] serde = ["dep:serde", "uncased/with-serde-alloc"]
uuid = ["uuid_"] uuid = ["dep:uuid"]
[lints.clippy] [lints.clippy]
module_inception = "allow" module_inception = "allow"
@ -39,15 +39,13 @@ stable-pattern = "0.1"
cookie = { version = "0.18", features = ["percent-encode"] } cookie = { version = "0.18", features = ["percent-encode"] }
state = "0.6" state = "0.6"
[dependencies.serde_] [dependencies.serde]
package = "serde"
version = "1.0" version = "1.0"
optional = true optional = true
default-features = false default-features = false
features = ["std"] features = ["std"]
[dependencies.uuid_] [dependencies.uuid]
package = "uuid"
version = "1" version = "1"
optional = true optional = true
default-features = false default-features = false

View File

@ -73,13 +73,12 @@ macro_rules! define_methods {
/// from either `"GET"` or `"get"` but not `"GeT"`. /// from either `"GET"` or `"get"` but not `"GeT"`.
/// ///
/// ```rust /// ```rust
/// # #[cfg(feature = "serde")] mod serde { /// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde_ as serde;
/// use serde::{Serialize, Deserialize};
/// use rocket::http::Method; /// use rocket::http::Method;
/// use rocket::serde::{Serialize, Deserialize};
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// #[serde(crate = "rocket::serde")]
/// struct Foo { /// struct Foo {
/// method: Method, /// method: Method,
/// } /// }
@ -357,11 +356,11 @@ impl PartialEq<Method> for &Method {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
mod serde { mod serde_impl {
use super::*; use super::*;
use serde_::ser::{Serialize, Serializer}; use serde::ser::{Serialize, Serializer};
use serde_::de::{Deserialize, Deserializer, Error, Visitor, Unexpected}; use serde::de::{Deserialize, Deserializer, Error, Visitor, Unexpected};
impl Serialize for Method { impl Serialize for Method {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {

View File

@ -901,8 +901,8 @@ impl RawStr {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
mod serde { mod serde_impl {
use serde_::{ser, de, Serialize, Deserialize}; use serde::{ser, de, Serialize, Deserialize};
use super::*; use super::*;

View File

@ -100,13 +100,13 @@ impl StatusClass {
/// range `[100, 600)` is allowed to deserialize into a `Status`.` /// range `[100, 600)` is allowed to deserialize into a `Status`.`
/// ///
/// ```rust /// ```rust
/// # #[cfg(feature = "serde")] mod serde { /// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde_ as serde; /// # use serde as serde;
/// use serde::{Serialize, Deserialize}; /// use serde::{Serialize, Deserialize};
/// use rocket::http::Status; /// use rocket::http::Status;
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct Foo { /// struct Foo {
/// status: Status, /// status: Status,
/// } /// }
@ -381,11 +381,11 @@ impl Ord for Status {
} }
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
mod serde { mod serde_impl {
use super::*; use super::*;
use serde_::ser::{Serialize, Serializer}; use serde::ser::{Serialize, Serializer};
use serde_::de::{Deserialize, Deserializer, Error, Visitor, Unexpected}; use serde::de::{Deserialize, Deserializer, Error, Visitor, Unexpected};
impl Serialize for Status { impl Serialize for Status {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {

View File

@ -72,19 +72,19 @@ use crate::uri::{Authority, Path, Query, Data, Error, as_utf8_unchecked, fmt};
/// `Absolute` is both `Serialize` and `Deserialize`: /// `Absolute` is both `Serialize` and `Deserialize`:
/// ///
/// ```rust /// ```rust
/// # #[cfg(feature = "serde")] mod serde { /// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde_ as serde; /// # use serde as serde;
/// use serde::{Serialize, Deserialize}; /// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Absolute; /// use rocket::http::uri::Absolute;
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct UriOwned { /// struct UriOwned {
/// uri: Absolute<'static>, /// uri: Absolute<'static>,
/// } /// }
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct UriBorrowed<'a> { /// struct UriBorrowed<'a> {
/// uri: Absolute<'a>, /// uri: Absolute<'a>,
/// } /// }

View File

@ -8,13 +8,13 @@ use crate::uri::Error;
/// `Asterisk` is both `Serialize` and `Deserialize`: /// `Asterisk` is both `Serialize` and `Deserialize`:
/// ///
/// ```rust /// ```rust
/// # #[cfg(feature = "serde")] mod serde { /// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde_ as serde; /// # use serde as serde;
/// use serde::{Serialize, Deserialize}; /// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Asterisk; /// use rocket::http::uri::Asterisk;
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct UriOwned { /// struct UriOwned {
/// uri: Asterisk, /// uri: Asterisk,
/// } /// }

View File

@ -25,19 +25,19 @@ use crate::uri::{as_utf8_unchecked, error::Error};
/// `Authority` is both `Serialize` and `Deserialize`: /// `Authority` is both `Serialize` and `Deserialize`:
/// ///
/// ```rust /// ```rust
/// # #[cfg(feature = "serde")] mod serde { /// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde_ as serde; /// # use serde as serde;
/// use serde::{Serialize, Deserialize}; /// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Authority; /// use rocket::http::uri::Authority;
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct UriOwned { /// struct UriOwned {
/// uri: Authority<'static>, /// uri: Authority<'static>,
/// } /// }
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct UriBorrowed<'a> { /// struct UriBorrowed<'a> {
/// uri: Authority<'a>, /// uri: Authority<'a>,
/// } /// }

View File

@ -505,8 +505,8 @@ impl<K: UriDisplay<Query>, V: UriDisplay<Query>> UriDisplay<Query> for BTreeMap<
} }
} }
#[cfg(feature = "uuid")] impl_with_display!(uuid_::Uuid); #[cfg(feature = "uuid")] impl_with_display!(uuid::Uuid);
#[cfg(feature = "uuid")] crate::impl_from_uri_param_identity!(uuid_::Uuid); #[cfg(feature = "uuid")] crate::impl_from_uri_param_identity!(uuid::Uuid);
// And finally, the `Ignorable` trait, which has sugar of `_` in the `uri!` // And finally, the `Ignorable` trait, which has sugar of `_` in the `uri!`
// macro, which expands to a typecheck. // macro, which expands to a typecheck.

View File

@ -69,19 +69,19 @@ use crate::uri::{Absolute, Authority};
/// `Host` is both `Serialize` and `Deserialize`: /// `Host` is both `Serialize` and `Deserialize`:
/// ///
/// ```rust /// ```rust
/// # #[cfg(feature = "serde")] mod serde { /// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde_ as serde; /// # use serde as serde;
/// use serde::{Serialize, Deserialize}; /// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Host; /// use rocket::http::uri::Host;
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct UriOwned { /// struct UriOwned {
/// uri: Host<'static>, /// uri: Host<'static>,
/// } /// }
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct UriBorrowed<'a> { /// struct UriBorrowed<'a> {
/// uri: Host<'a>, /// uri: Host<'a>,
/// } /// }

View File

@ -93,19 +93,19 @@ use crate::{RawStr, RawStrBuf};
/// `Origin` is both `Serialize` and `Deserialize`: /// `Origin` is both `Serialize` and `Deserialize`:
/// ///
/// ```rust /// ```rust
/// # #[cfg(feature = "serde")] mod serde { /// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde_ as serde; /// # use serde as serde;
/// use serde::{Serialize, Deserialize}; /// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Origin; /// use rocket::http::uri::Origin;
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct UriOwned { /// struct UriOwned {
/// uri: Origin<'static>, /// uri: Origin<'static>,
/// } /// }
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct UriBorrowed<'a> { /// struct UriBorrowed<'a> {
/// uri: Origin<'a>, /// uri: Origin<'a>,
/// } /// }

View File

@ -51,19 +51,19 @@ use crate::parse::{Extent, IndexedStr};
/// `Reference` is both `Serialize` and `Deserialize`: /// `Reference` is both `Serialize` and `Deserialize`:
/// ///
/// ```rust /// ```rust
/// # #[cfg(feature = "serde")] mod serde { /// # #[cfg(feature = "serde")] mod serde_impl {
/// # use serde_ as serde; /// # use serde as serde;
/// use serde::{Serialize, Deserialize}; /// use serde::{Serialize, Deserialize};
/// use rocket::http::uri::Reference; /// use rocket::http::uri::Reference;
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct UriOwned { /// struct UriOwned {
/// uri: Reference<'static>, /// uri: Reference<'static>,
/// } /// }
/// ///
/// #[derive(Deserialize, Serialize)] /// #[derive(Deserialize, Serialize)]
/// # #[serde(crate = "serde_")] /// # #[serde(crate = "serde")]
/// struct UriBorrowed<'a> { /// struct UriBorrowed<'a> {
/// uri: Reference<'a>, /// uri: Reference<'a>,
/// } /// }

View File

@ -365,13 +365,13 @@ impl_uri_from!(Asterisk);
macro_rules! impl_serde { macro_rules! impl_serde {
($T:ty, $expected:literal) => { ($T:ty, $expected:literal) => {
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
mod serde { mod serde_impl {
use std::fmt; use std::fmt;
use std::marker::PhantomData; use std::marker::PhantomData;
use super::*; use super::*;
use serde_::ser::{Serialize, Serializer}; use serde::ser::{Serialize, Serializer};
use serde_::de::{Deserialize, Deserializer, Error, Visitor}; use serde::de::{Deserialize, Deserializer, Error, Visitor};
impl<'a> Serialize for $T { impl<'a> Serialize for $T {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {