Skip to content

Commit 9b372af

Browse files
committed
remove no longer needed marker
1 parent d13c649 commit 9b372af

11 files changed

Lines changed: 72 additions & 38 deletions

File tree

cot-core/src/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
//! Error handling types and utilities for Cot applications.
2+
//!
3+
//! This module provides error types, error handlers, and utilities for
4+
//! handling various types of errors that can occur in Cot applications,
5+
//! including 404 Not Found errors, uncaught panics, and custom error pages.
6+
17
pub mod backtrace;
28
pub(crate) mod error_impl;
39
mod method_not_allowed;

cot-core/src/handler.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
//! Request handler traits and utilities.
2+
//!
3+
//! This module provides the [`RequestHandler`] trait, which is the core
4+
//! abstraction for handling HTTP requests in Cot. It is automatically
5+
//! implemented for async functions taking extractors and returning responses.
6+
17
use std::future::Future;
28
use std::marker::PhantomData;
39
use std::pin::Pin;
@@ -72,12 +78,6 @@ pub fn into_box_request_handler<T, H: RequestHandler<T> + Send + Sync>(
7278
Inner(handler, PhantomData)
7379
}
7480

75-
/// Private marker type used to distinguish `FromRequest` parameter position in
76-
/// trait impls. This is used instead of `()` to avoid coherence conflicts.
77-
#[doc(hidden)]
78-
#[expect(missing_copy_implementations, missing_debug_implementations)]
79-
pub struct FromRequestMarker(());
80-
8181
macro_rules! impl_request_handler {
8282
($($ty:ident),*) => {
8383
impl<Func, $($ty,)* Fut, R> RequestHandler<($($ty,)*)> for Func
@@ -112,7 +112,7 @@ macro_rules! impl_request_handler {
112112

113113
macro_rules! impl_request_handler_from_request {
114114
($($ty_lhs:ident,)* ($ty_from_request:ident) $(,$ty_rhs:ident)*) => {
115-
impl<Func, $($ty_lhs,)* $ty_from_request, $($ty_rhs,)* Fut, R> RequestHandler<($($ty_lhs,)* $ty_from_request, FromRequestMarker, $($ty_rhs,)*)> for Func
115+
impl<Func, $($ty_lhs,)* $ty_from_request, $($ty_rhs,)* Fut, R> RequestHandler<($($ty_lhs,)* $ty_from_request, (), $($ty_rhs,)*)> for Func
116116
where
117117
Func: FnOnce($($ty_lhs,)* $ty_from_request, $($ty_rhs),*) -> Fut + Clone + Send + Sync + 'static,
118118
$($ty_lhs: FromRequestHead + Send,)*
@@ -239,14 +239,16 @@ pub use handle_all_parameters;
239239
handle_all_parameters!(impl_request_handler);
240240
handle_all_parameters_from_request!(impl_request_handler_from_request);
241241

242+
#[rustfmt::skip] // `wrap_comments` breaks local links
242243
/// A wrapper around a handler that's used in
243-
/// [`Bootstrapper`](cot::Bootstrapper).
244+
/// [`Bootstrapper`](../../cot/project/struct.Bootstrapper.html).
244245
///
245246
/// It is returned by
246-
/// [`Bootstrapper::into_bootstrapped_project`](cot::Bootstrapper::finish).
247-
/// Typically, you don't need to interact with this type directly, except for
248-
/// creating it in [`Project::middlewares`](cot::Project::middlewares) through
249-
/// the [`RootHandlerBuilder::build`](cot::project::RootHandlerBuilder::build)
247+
/// [`Bootstrapper::finish()`](../../cot/project/struct.Bootstrapper.html#method.finish).
248+
/// Typically, you don't need to interact with this type directly, except
249+
/// for creating it in
250+
/// [`Project::middlewares()`](../../cot/project/trait.Project.html#method.middlewares) through the
251+
/// [`RootHandlerBuilder::build()`](../../cot/project/struct.RootHandlerBuilder.html#method.build)
250252
/// method.
251253
///
252254
/// # Examples

cot-core/src/headers.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! HTTP header constants.
2+
//!
3+
//! This module provides commonly used content type header values.
4+
15
pub const HTML_CONTENT_TYPE: &str = "text/html; charset=utf-8";
26
pub const MULTIPART_FORM_CONTENT_TYPE: &str = "multipart/form-data";
37
pub const URLENCODED_FORM_CONTENT_TYPE: &str = "application/x-www-form-urlencoded";

cot-core/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
//! Core types and functionality for the Cot web framework.
2+
//!
3+
//! This crate provides the foundational building blocks for
4+
//! [Cot](https://docs.rs/cot/latest/cot/), including HTTP primitives, body handling, error
5+
//! types, handlers, middleware, and request/response types.
6+
//!
7+
//! Most applications should use the main `cot` crate rather than depending on
8+
//! `cot-core` directly. This crate is primarily intended for internal use by
9+
//! the Cot framework and for building custom extensions.
10+
111
mod body;
212

313
pub mod error;

cot-core/src/middleware.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
//! Middlewares for modifying requests and responses.
2+
//!
3+
//! Middlewares are used to modify requests and responses in a pipeline. They
4+
//! are used to add functionality to the request/response cycle, such as
5+
//! session management, adding security headers, and more.
6+
17
use std::fmt::Debug;
28
use std::task::{Context, Poll};
39

@@ -11,13 +17,14 @@ use crate::request::Request;
1117
use crate::response::Response;
1218
use crate::{Body, Error};
1319

14-
/// Middleware that converts a any [`http::Response`] generic type to a
15-
/// [`cot::response::Response`].
20+
#[rustfmt::skip] // `wrap_comments` breaks local links
21+
/// Middleware that converts any [`http::Response`] generic type
22+
/// to a [`Response`].
1623
///
1724
/// This is useful for converting a response from a middleware that is
1825
/// compatible with the `tower` crate to a response that is compatible with
1926
/// Cot. It's applied automatically by
20-
/// [`RootHandlerBuilder::middleware()`](cot::project::RootHandlerBuilder::middleware())
27+
/// [`RootHandlerBuilder::middleware()`](../../cot/project/struct.RootHandlerBuilder.html#method.middleware)
2128
/// and is not needed to be added manually.
2229
///
2330
/// # Examples
@@ -74,8 +81,8 @@ impl<S> tower::Layer<S> for IntoCotResponseLayer {
7481
}
7582
}
7683

77-
/// Service struct that converts any [`http::Response`] generic type to
78-
/// [`cot::response::Response`].
84+
/// Service struct that converts any [`http::Response`] generic
85+
/// type to [`Response`].
7986
///
8087
/// Used by [`IntoCotResponseLayer`].
8188
///
@@ -125,12 +132,13 @@ where
125132
response.map(|body| Body::wrapper(BoxBody::new(body.map_err(map_err))))
126133
}
127134

128-
/// Middleware that converts any error type to [`cot::Error`].
135+
#[rustfmt::skip] // `wrap_comments` breaks local links
136+
/// Middleware that converts any error type to [`Error`].
129137
///
130138
/// This is useful for converting a response from a middleware that is
131139
/// compatible with the `tower` crate to a response that is compatible with
132140
/// Cot. It's applied automatically by
133-
/// [`RootHandlerBuilder::middleware()`](cot::project::RootHandlerBuilder::middleware())
141+
/// [`RootHandlerBuilder::middleware`](../../cot/project/struct.RootHandlerBuilder.html#method.middleware)
134142
/// and is not needed to be added manually.
135143
///
136144
/// # Examples
@@ -187,7 +195,7 @@ impl<S> tower::Layer<S> for IntoCotErrorLayer {
187195
}
188196
}
189197

190-
/// Service struct that converts a any error type to a [`cot::Error`].
198+
/// Service struct that converts a any error type to a [`Error`].
191199
///
192200
/// Used by [`IntoCotErrorLayer`].
193201
///

cot-core/src/request.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
//!
33
//! Cot uses the [`Request`](http::Request) type from the [`http`] crate
44
//! to represent incoming HTTP requests. However, it also provides a
5-
//! [`RequestExt`] trait that contain various helper methods for working with
6-
//! HTTP requests. These methods are used to access the application context,
7-
//! project configuration, path parameters, and more. You probably want to have
8-
//! a `use` statement for [`RequestExt`] in your code most of the time to be
9-
//! able to use these functions:
5+
//! [`RequestExt`](../../cot/request/trait.RequestExt.html) trait that contain
6+
//! various helper methods for working with HTTP requests. These methods are
7+
//! used to access the application context, project configuration, path
8+
//! parameters, and more. You probably want to have a `use` statement for
9+
//! [`RequestExt`](../../cot/request/trait.RequestExt.html) in your code most of
10+
//! the time to be able to use these functions:
1011
//!
1112
//! ```
1213
//! use cot::request::RequestExt;
@@ -45,7 +46,7 @@ pub struct RouteName(pub String);
4546
/// Path parameters extracted from the request URL, and available as a map of
4647
/// strings.
4748
///
48-
/// This struct is meant to be mainly used using the [`PathParams::parse`]
49+
/// This struct is meant to be mainly used via the [`PathParams::parse`]
4950
/// method, which will deserialize the path parameters into a type `T`
5051
/// implementing `serde::DeserializeOwned`. If needed, you can also access the
5152
/// path parameters directly using the [`PathParams::get`] method.

cot-core/src/response.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ pub trait ResponseExt: Sized + private::Sealed {
122122
///
123123
/// # See also
124124
///
125-
/// * [`crate::reverse_redirect!`] – a more ergonomic way to create
126-
/// redirects to internal views
125+
/// * [`cot::reverse_redirect!`](../../cot/macro.reverse_redirect!.html) – a
126+
/// more ergonomic way to create redirects to internal views (available in
127+
/// the `cot` crate)
127128
#[must_use]
128129
fn new_redirect<T: Into<String>>(location: T) -> Self;
129130
}

cot/src/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
//! Error handling types and utilities for Cot applications.
2+
//!
3+
//! This module provides error types, error handlers, and utilities for
4+
//! handling various types of errors that can occur in Cot applications,
5+
//! including 404 Not Found errors, uncaught panics, and custom error pages.
6+
17
pub mod handler;
28

39
#[doc(inline)]

cot/src/error/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::response::Response;
2020
/// This trait is implemented by functions that can handle error pages. The
2121
/// trait is automatically implemented for async functions that take parameters
2222
/// implementing [`FromRequestHead`] and return a type that implements
23-
/// [`IntoResponse`].
23+
/// [`IntoResponse`](crate::response::IntoResponse).
2424
///
2525
/// # Examples
2626
///

cot/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ pub mod cache;
5555

5656
#[cfg(feature = "db")]
5757
pub mod db;
58-
/// Error handling types and utilities for Cot applications.
59-
///
60-
/// This module provides error types, error handlers, and utilities for
61-
/// handling various types of errors that can occur in Cot applications,
62-
/// including 404 Not Found errors, uncaught panics, and custom error pages.
6358
pub mod error;
6459
pub mod form;
6560
// Not public API. Referenced by macro-generated code.

0 commit comments

Comments
 (0)