Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions axum-extra/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ allowed = [
"http_body",
"pin_project_lite",
"prost",
"serde",
"serde_core",
"tokio",
"tokio_util",
"tower_layer",
Expand Down Expand Up @@ -78,10 +78,8 @@ typed-routing = [
]

# Enabled by docs.rs because it uses all-features
__private_docs = [
# Required for the ErasedJson docs to be able to link to axum::Json
"axum/json",
]
# Enables upstream things linked to in docs
__private_docs = ["axum/json", "dep:serde"]

[dependencies]
axum = { path = "../axum", version = "0.8.4", default-features = false, features = ["original-uri"] }
Expand All @@ -95,7 +93,7 @@ http-body-util = "0.1.0"
mime = "0.3"
pin-project-lite = "0.2"
rustversion = "1.0.9"
serde = "1.0"
serde_core = "1.0.221"
tower = { version = "0.5.2", default-features = false, features = ["util"] }
tower-layer = "0.3"
tower-service = "0.3"
Expand All @@ -118,12 +116,15 @@ tokio-util = { version = "0.7", optional = true }
tracing = { version = "0.1.37", default-features = false, optional = true }
typed-json = { version = "0.1.1", optional = true }

# doc dependencies
serde = { version = "1.0.221", optional = true }

[dev-dependencies]
axum = { path = "../axum", features = ["macros", "__private"] }
axum-macros = { path = "../axum-macros", features = ["__private"] }
hyper = "1.0.0"
reqwest = { version = "0.12", default-features = false, features = ["json", "stream", "multipart"] }
serde = { version = "1.0", features = ["derive"] }
serde = { version = "1.0.221", features = ["derive"] }
serde_json = "1.0.71"
tokio = { version = "1.14", features = ["full"] }
tower = { version = "0.5.2", features = ["util"] }
Expand Down
2 changes: 1 addition & 1 deletion axum-extra/src/extract/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use axum::{
};
use axum_core::__composite_rejection as composite_rejection;
use axum_core::__define_rejection as define_rejection;
use serde::de::DeserializeOwned;
use serde_core::de::DeserializeOwned;

/// Extractor that deserializes `application/x-www-form-urlencoded` requests
/// into some type.
Expand Down
2 changes: 1 addition & 1 deletion axum-extra/src/extract/json_deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use axum_core::__define_rejection as define_rejection;
use axum_core::extract::rejection::BytesRejection;
use bytes::Bytes;
use http::{header, HeaderMap};
use serde::Deserialize;
use serde_core::Deserialize;
use std::marker::PhantomData;

/// JSON Extractor for zero-copy deserialization.
Expand Down
2 changes: 1 addition & 1 deletion axum-extra/src/extract/optional_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use axum::{
extract::{rejection::PathRejection, FromRequestParts, Path},
RequestPartsExt,
};
use serde::de::DeserializeOwned;
use serde_core::de::DeserializeOwned;

/// Extractor that extracts path arguments the same way as [`Path`], except if there aren't any.
///
Expand Down
2 changes: 1 addition & 1 deletion axum-extra/src/extract/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use axum::extract::FromRequestParts;
use axum_core::__composite_rejection as composite_rejection;
use axum_core::__define_rejection as define_rejection;
use http::{request::Parts, Uri};
use serde::de::DeserializeOwned;
use serde_core::de::DeserializeOwned;

/// Extractor that deserializes query strings into some type.
///
Expand Down
8 changes: 4 additions & 4 deletions axum-extra/src/json_lines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bytes::{BufMut, BytesMut};
use futures_core::{stream::BoxStream, Stream, TryStream};
use futures_util::stream::TryStreamExt;
use pin_project_lite::pin_project;
use serde::{de::DeserializeOwned, Serialize};
use serde_core::{de::DeserializeOwned, Serialize};
use std::{
convert::Infallible,
io::{self, Write},
Expand Down Expand Up @@ -174,16 +174,16 @@ where

#[cfg(test)]
mod tests {
use super::*;
use super::JsonLines;
use crate::test_helpers::*;
use axum::{
routing::{get, post},
Router,
};
use futures_util::StreamExt;
use http::StatusCode;
use serde::Deserialize;
use std::error::Error;
use serde::{Deserialize, Serialize};
use std::{convert::Infallible, error::Error};

#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)]
struct User {
Expand Down
2 changes: 1 addition & 1 deletion axum-extra/src/response/erased_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use axum::{
response::{IntoResponse, Response},
};
use bytes::{BufMut, Bytes, BytesMut};
use serde::Serialize;
use serde_core::Serialize;

/// A response type that holds a JSON in serialized form.
///
Expand Down
5 changes: 2 additions & 3 deletions axum-extra/src/routing/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{any::type_name, fmt};

use super::sealed::Sealed;
use http::Uri;
use serde::Serialize;
use serde_core::Serialize;

/// A type safe path.
///
Expand Down Expand Up @@ -384,7 +384,6 @@ impl_second_element_is!(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,

#[cfg(test)]
mod tests {
use super::*;
use crate::{
extract::WithRejection,
routing::{RouterExt, TypedPath},
Expand All @@ -394,7 +393,7 @@ mod tests {
response::{IntoResponse, Response},
Router,
};
use serde::Deserialize;
use serde::{Deserialize, Serialize};

#[derive(TypedPath, Deserialize)]
#[typed_path("/users/{id}")]
Expand Down
16 changes: 8 additions & 8 deletions axum-macros/tests/debug_handler/fail/json_not_deserialize.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error[E0277]: the trait bound `for<'de> Struct: serde::de::Deserialize<'de>` is not satisfied
error[E0277]: the trait bound `Struct: serde::Deserialize<'de>` is not satisfied
--> tests/debug_handler/fail/json_not_deserialize.rs:7:24
|
7 | async fn handler(_foo: Json<Struct>) {}
| ^^^^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `Struct`, which is required by `Json<Struct>: FromRequest<()>`
| ^^^^^^^^^^^^ the trait `for<'de> serde_core::de::Deserialize<'de>` is not implemented for `Struct`, which is required by `Json<Struct>: FromRequest<()>`
|
= note: for local types consider adding `#[derive(serde::Deserialize)]` to your `Struct` type
= note: for types from other crates check whether the crate offers a `serde` feature flag
= help: the following other types implement trait `serde::de::Deserialize<'de>`:
= help: the following other types implement trait `serde_core::de::Deserialize<'de>`:
&'a [u8]
&'a serde_json::raw::RawValue
&'a std::path::Path
Expand All @@ -16,23 +16,23 @@ error[E0277]: the trait bound `for<'de> Struct: serde::de::Deserialize<'de>` is
(T0, T1)
(T0, T1, T2)
and $N others
= note: required for `Struct` to implement `serde::de::DeserializeOwned`
= note: required for `Struct` to implement `serde_core::de::DeserializeOwned`
= note: required for `Json<Struct>` to implement `FromRequest<()>`
= help: see issue #48214
help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
|
1 + #![feature(trivial_bounds)]
|

error[E0277]: the trait bound `for<'de> Struct: serde::de::Deserialize<'de>` is not satisfied
error[E0277]: the trait bound `Struct: serde::Deserialize<'de>` is not satisfied
--> tests/debug_handler/fail/json_not_deserialize.rs:7:24
|
7 | async fn handler(_foo: Json<Struct>) {}
| ^^^^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `Struct`, which is required by `Json<Struct>: FromRequest<()>`
| ^^^^^^^^^^^^ the trait `for<'de> serde_core::de::Deserialize<'de>` is not implemented for `Struct`, which is required by `Json<Struct>: FromRequest<()>`
|
= note: for local types consider adding `#[derive(serde::Deserialize)]` to your `Struct` type
= note: for types from other crates check whether the crate offers a `serde` feature flag
= help: the following other types implement trait `serde::de::Deserialize<'de>`:
= help: the following other types implement trait `serde_core::de::Deserialize<'de>`:
&'a [u8]
&'a serde_json::raw::RawValue
&'a std::path::Path
Expand All @@ -42,7 +42,7 @@ error[E0277]: the trait bound `for<'de> Struct: serde::de::Deserialize<'de>` is
(T0, T1)
(T0, T1, T2)
and $N others
= note: required for `Struct` to implement `serde::de::DeserializeOwned`
= note: required for `Struct` to implement `serde_core::de::DeserializeOwned`
= note: required for `Json<Struct>` to implement `FromRequest<()>`
note: required by a bound in `__axum_macros_check_handler_0_from_request_check`
--> tests/debug_handler/fail/json_not_deserialize.rs:7:24
Expand Down
20 changes: 10 additions & 10 deletions axum-macros/tests/typed_path/fail/not_deserialize.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error[E0277]: the trait bound `for<'de> MyPath: serde::de::Deserialize<'de>` is not satisfied
error[E0277]: the trait bound `MyPath: serde::Deserialize<'de>` is not satisfied
--> tests/typed_path/fail/not_deserialize.rs:3:10
|
3 | #[derive(TypedPath)]
| ^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `MyPath`, which is required by `axum::extract::Path<MyPath>: FromRequestParts<S>`
| ^^^^^^^^^ the trait `for<'de> serde_core::de::Deserialize<'de>` is not implemented for `MyPath`, which is required by `axum::extract::Path<MyPath>: FromRequestParts<S>`
|
= note: for local types consider adding `#[derive(serde::Deserialize)]` to your `MyPath` type
= note: for types from other crates check whether the crate offers a `serde` feature flag
= help: the following other types implement trait `serde::de::Deserialize<'de>`:
= help: the following other types implement trait `serde_core::de::Deserialize<'de>`:
&'a [u8]
&'a serde_json::raw::RawValue
&'a std::path::Path
Expand All @@ -16,16 +16,16 @@ error[E0277]: the trait bound `for<'de> MyPath: serde::de::Deserialize<'de>` is
(T0, T1)
(T0, T1, T2)
and $N others
= note: required for `MyPath` to implement `serde::de::DeserializeOwned`
= note: required for `MyPath` to implement `serde_core::de::DeserializeOwned`
= note: required for `axum::extract::Path<MyPath>` to implement `FromRequestParts<S>`

error[E0277]: the trait bound `MyPath: serde::de::DeserializeOwned` is not satisfied
--> tests/typed_path/fail/not_deserialize.rs:3:10
|
3 | #[derive(TypedPath)]
| ^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `MyPath`, which is required by `axum::extract::Path<MyPath>: FromRequestParts<S>`
| ^^^^^^^^^ the trait `for<'de> serde_core::de::Deserialize<'de>` is not implemented for `MyPath`, which is required by `axum::extract::Path<MyPath>: FromRequestParts<S>`
|
= help: the following other types implement trait `serde::de::Deserialize<'de>`:
= help: the following other types implement trait `serde_core::de::Deserialize<'de>`:
&'a [u8]
&'a serde_json::raw::RawValue
&'a std::path::Path
Expand All @@ -35,16 +35,16 @@ error[E0277]: the trait bound `MyPath: serde::de::DeserializeOwned` is not satis
(T0, T1)
(T0, T1, T2)
and $N others
= note: required for `MyPath` to implement `serde::de::DeserializeOwned`
= note: required for `MyPath` to implement `serde_core::de::DeserializeOwned`
= note: required for `axum::extract::Path<MyPath>` to implement `FromRequestParts<S>`

error[E0277]: the trait bound `MyPath: serde::de::DeserializeOwned` is not satisfied
--> tests/typed_path/fail/not_deserialize.rs:3:10
|
3 | #[derive(TypedPath)]
| ^^^^^^^^^ the trait `for<'de> serde::de::Deserialize<'de>` is not implemented for `MyPath`, which is required by `axum::extract::Path<MyPath>: FromRequestParts<S>`
| ^^^^^^^^^ the trait `for<'de> serde_core::de::Deserialize<'de>` is not implemented for `MyPath`, which is required by `axum::extract::Path<MyPath>: FromRequestParts<S>`
|
= help: the following other types implement trait `serde::de::Deserialize<'de>`:
= help: the following other types implement trait `serde_core::de::Deserialize<'de>`:
&'a [u8]
&'a serde_json::raw::RawValue
&'a std::path::Path
Expand All @@ -54,6 +54,6 @@ error[E0277]: the trait bound `MyPath: serde::de::DeserializeOwned` is not satis
(T0, T1)
(T0, T1, T2)
and $N others
= note: required for `MyPath` to implement `serde::de::DeserializeOwned`
= note: required for `MyPath` to implement `serde_core::de::DeserializeOwned`
= note: required for `axum::extract::Path<MyPath>` to implement `FromRequestParts<S>`
= note: this error originates in the derive macro `TypedPath` (in Nightly builds, run with -Z macro-backtrace for more info)
10 changes: 7 additions & 3 deletions axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ allowed = [
"bytes",
"http",
"http_body",
"serde",
"serde_core",
"tokio",
# for the `__private` feature
"reqwest",
Expand Down Expand Up @@ -78,6 +78,7 @@ __private_docs = [
"axum-core/__private_docs",
# Enables upstream things linked to in docs
"tower/full",
"dep:serde",
"dep:tower-http",
]

Expand All @@ -100,7 +101,7 @@ memchr = "2.4.1"
mime = "0.3.16"
percent-encoding = "2.1"
pin-project-lite = "0.2.7"
serde = "1.0"
serde_core = "1.0.221"
sync_wrapper = "1.0.0"
tower = { version = "0.5.2", default-features = false, features = ["util"] }
tower-layer = "0.3.2"
Expand All @@ -122,6 +123,9 @@ tokio = { package = "tokio", version = "1.44", features = ["time"], optional = t
tokio-tungstenite = { version = "0.27.0", optional = true }
tracing = { version = "0.1", default-features = false, optional = true }

# doc dependencies
serde = { version = "1.0.211", optional = true }

[dependencies.tower-http]
version = "0.6.0"
optional = true
Expand Down Expand Up @@ -165,7 +169,7 @@ hyper = { version = "1.1.0", features = ["client"] }
quickcheck = "1.0"
quickcheck_macros = "1.0"
reqwest = { version = "0.12", default-features = false, features = ["json", "stream", "multipart"] }
serde = { version = "1.0", features = ["derive"] }
serde = { version = "1.0.221", features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
time = { version = "0.3", features = ["serde-human-readable"] }
tokio = { package = "tokio", version = "1.44.2", features = ["macros", "rt", "rt-multi-thread", "net", "test-util"] }
Expand Down
2 changes: 1 addition & 1 deletion axum/src/extract/path/de.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{ErrorKind, PathDeserializationError};
use crate::util::PercentDecodedStr;
use serde::{
use serde_core::{
de::{self, DeserializeSeed, EnumAccess, Error, MapAccess, SeqAccess, VariantAccess, Visitor},
forward_to_deserialize_any, Deserializer,
};
Expand Down
Loading
Loading