mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-01 00:00:14 +02:00
Fix doc(cfg)s (#765)
* Use automatic doc(cfg) attributes where possible * Add missing feature documentation * Replace redundant cfg attribute with doc(cfg) * Remove non-existent feature from package.metadata.playground.features * Add missing cfg's on rejection types
This commit is contained in:
committed by
David Pedersen
parent
9e05351d8f
commit
2e83dff4d1
+5
-6
@@ -83,10 +83,9 @@ rustdoc-args = ["--cfg", "docsrs"]
|
|||||||
|
|
||||||
[package.metadata.playground]
|
[package.metadata.playground]
|
||||||
features = [
|
features = [
|
||||||
"http1",
|
"http1",
|
||||||
"http2",
|
"http2",
|
||||||
"json",
|
"json",
|
||||||
"multipart",
|
"multipart",
|
||||||
"tower",
|
"ws",
|
||||||
"ws",
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ pub mod path;
|
|||||||
pub mod rejection;
|
pub mod rejection;
|
||||||
|
|
||||||
#[cfg(feature = "ws")]
|
#[cfg(feature = "ws")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
|
|
||||||
pub mod ws;
|
pub mod ws;
|
||||||
|
|
||||||
mod content_length_limit;
|
mod content_length_limit;
|
||||||
@@ -43,25 +42,20 @@ pub use self::{
|
|||||||
pub use crate::Json;
|
pub use crate::Json;
|
||||||
|
|
||||||
#[cfg(feature = "multipart")]
|
#[cfg(feature = "multipart")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "multipart")))]
|
|
||||||
pub mod multipart;
|
pub mod multipart;
|
||||||
|
|
||||||
#[cfg(feature = "multipart")]
|
#[cfg(feature = "multipart")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "multipart")))]
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use self::multipart::Multipart;
|
pub use self::multipart::Multipart;
|
||||||
|
|
||||||
#[cfg(feature = "ws")]
|
#[cfg(feature = "ws")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use self::ws::WebSocketUpgrade;
|
pub use self::ws::WebSocketUpgrade;
|
||||||
|
|
||||||
#[cfg(feature = "headers")]
|
#[cfg(feature = "headers")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "headers")))]
|
|
||||||
mod typed_header;
|
mod typed_header;
|
||||||
|
|
||||||
#[cfg(feature = "headers")]
|
#[cfg(feature = "headers")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "headers")))]
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use self::typed_header::TypedHeader;
|
pub use self::typed_header::TypedHeader;
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ use std::{
|
|||||||
///
|
///
|
||||||
/// For security reasons its recommended to combine this with
|
/// For security reasons its recommended to combine this with
|
||||||
/// [`ContentLengthLimit`](super::ContentLengthLimit) to limit the size of the request payload.
|
/// [`ContentLengthLimit`](super::ContentLengthLimit) to limit the size of the request payload.
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "multipart")))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Multipart {
|
pub struct Multipart {
|
||||||
inner: multer::Multipart<'static>,
|
inner: multer::Multipart<'static>,
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ define_rejection! {
|
|||||||
pub struct InvalidJsonBody(Error);
|
pub struct InvalidJsonBody(Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "json")]
|
||||||
define_rejection! {
|
define_rejection! {
|
||||||
#[status = UNSUPPORTED_MEDIA_TYPE]
|
#[status = UNSUPPORTED_MEDIA_TYPE]
|
||||||
#[body = "Expected request with `Content-Type: application/json`"]
|
#[body = "Expected request with `Content-Type: application/json`"]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
|
||||||
/// Rejection type for [`Json`](super::Json) used if the `Content-Type`
|
/// Rejection type for [`Json`](super::Json) used if the `Content-Type`
|
||||||
/// header is missing.
|
/// header is missing.
|
||||||
pub struct MissingJsonContentType;
|
pub struct MissingJsonContentType;
|
||||||
@@ -243,5 +245,4 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "headers")]
|
#[cfg(feature = "headers")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "headers")))]
|
|
||||||
pub use super::typed_header::{TypedHeaderRejection, TypedHeaderRejectionReason};
|
pub use super::typed_header::{TypedHeaderRejection, TypedHeaderRejectionReason};
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ use std::ops::Deref;
|
|||||||
/// # axum::Server::bind(&"".parse().unwrap()).serve(app.into_make_service()).await.unwrap();
|
/// # axum::Server::bind(&"".parse().unwrap()).serve(app.into_make_service()).await.unwrap();
|
||||||
/// # };
|
/// # };
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(feature = "headers")]
|
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "headers")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "headers")))]
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct TypedHeader<T>(pub T);
|
pub struct TypedHeader<T>(pub T);
|
||||||
@@ -77,7 +76,6 @@ impl<T> Deref for TypedHeader<T> {
|
|||||||
|
|
||||||
/// Rejection used for [`TypedHeader`](super::TypedHeader).
|
/// Rejection used for [`TypedHeader`](super::TypedHeader).
|
||||||
#[cfg(feature = "headers")]
|
#[cfg(feature = "headers")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "headers")))]
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TypedHeaderRejection {
|
pub struct TypedHeaderRejection {
|
||||||
name: &'static http::header::HeaderName,
|
name: &'static http::header::HeaderName,
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ use tokio_tungstenite::{
|
|||||||
///
|
///
|
||||||
/// See the [module docs](self) for an example.
|
/// See the [module docs](self) for an example.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
|
||||||
pub struct WebSocketUpgrade {
|
pub struct WebSocketUpgrade {
|
||||||
config: WebSocketConfig,
|
config: WebSocketConfig,
|
||||||
/// The chosen protocol sent in the `Sec-WebSocket-Protocol` header of the response.
|
/// The chosen protocol sent in the `Sec-WebSocket-Protocol` header of the response.
|
||||||
|
|||||||
+1
-1
@@ -386,7 +386,7 @@
|
|||||||
#![deny(unreachable_pub, private_in_public)]
|
#![deny(unreachable_pub, private_in_public)]
|
||||||
#![allow(elided_lifetimes_in_paths, clippy::type_complexity)]
|
#![allow(elided_lifetimes_in_paths, clippy::type_complexity)]
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]
|
||||||
#![cfg_attr(test, allow(clippy::float_cmp))]
|
#![cfg_attr(test, allow(clippy::float_cmp))]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|||||||
@@ -210,8 +210,7 @@ impl Event {
|
|||||||
///
|
///
|
||||||
/// [`MessageEvent`'s data field]: https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
|
/// [`MessageEvent`'s data field]: https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
|
||||||
#[cfg(feature = "json")]
|
#[cfg(feature = "json")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
|
pub fn json_data<T>(mut self, data: T) -> serde_json::Result<Event>
|
||||||
pub fn json_data<T>(mut self, data: T) -> Result<Event, serde_json::Error>
|
|
||||||
where
|
where
|
||||||
T: serde::Serialize,
|
T: serde::Serialize,
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user