Skip to content

Commit ea496f2

Browse files
committed
hide private items
1 parent 3aecce1 commit ea496f2

8 files changed

Lines changed: 17 additions & 56 deletions

File tree

cot-core/src/body.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ use crate::{Error, Result};
3333
/// ```
3434
#[derive(Debug)]
3535
pub struct Body {
36-
pub inner: BodyInner,
36+
pub(crate) inner: BodyInner,
3737
}
3838

39-
pub enum BodyInner {
39+
pub(crate) enum BodyInner {
4040
Fixed(Bytes),
4141
Streaming(SyncWrapper<Pin<Box<dyn Stream<Item = Result<Bytes>> + Send>>>),
4242
Axum(SyncWrapper<axum::body::Body>),
@@ -171,12 +171,13 @@ impl Body {
171171
}
172172

173173
#[must_use]
174+
#[doc(hidden)]
174175
pub fn axum(inner: axum::body::Body) -> Self {
175176
Self::new(BodyInner::Axum(SyncWrapper::new(inner)))
176177
}
177178

178179
#[must_use]
179-
pub fn wrapper(inner: BoxBody<Bytes, Error>) -> Self {
180+
pub(crate) fn wrapper(inner: BoxBody<Bytes, Error>) -> Self {
180181
Self::new(BodyInner::Wrapper(inner))
181182
}
182183
}

cot-core/src/error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
pub mod backtrace;
88
pub(crate) mod error_impl;
99
mod method_not_allowed;
10-
mod not_found;
1110
mod uncaught_panic;
1211

1312
pub use error_impl::{Error, impl_into_cot_error};
1413
pub use method_not_allowed::MethodNotAllowed;
15-
pub use not_found::{Kind as NotFoundKind, NotFound};
1614
pub use uncaught_panic::UncaughtPanic;

cot-core/src/error/error_impl.rs

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::StatusCode;
88
// Need to rename Backtrace to CotBacktrace, because otherwise it triggers special behavior
99
// in the thiserror library
1010
use crate::error::backtrace::{__cot_create_backtrace, Backtrace as CotBacktrace};
11-
use crate::error::not_found::NotFound;
1211

1312
/// An error that can occur while using Cot.
1413
pub struct Error {
@@ -151,46 +150,6 @@ impl Error {
151150
Self::internal(error)
152151
}
153152

154-
/// Create a new "404 Not Found" error without a message.
155-
///
156-
/// # Examples
157-
///
158-
/// ```
159-
/// use cot::Error;
160-
///
161-
/// let error = Error::not_found();
162-
/// ```
163-
#[must_use]
164-
#[deprecated(
165-
note = "Use `cot::Error::from(cot::error::NotFound::new())` instead",
166-
since = "0.4.0"
167-
)]
168-
pub fn not_found() -> Self {
169-
Self::from(NotFound::new())
170-
}
171-
172-
/// Create a new "404 Not Found" error with a message.
173-
///
174-
/// Note that the message is only displayed when Cot's debug mode is
175-
/// enabled. It will not be exposed to the user in production.
176-
///
177-
/// # Examples
178-
///
179-
/// ```
180-
/// use cot::Error;
181-
///
182-
/// let id = 123;
183-
/// let error = Error::not_found_message(format!("User with id={id} not found"));
184-
/// ```
185-
#[must_use]
186-
#[deprecated(
187-
note = "Use `cot::Error::from(cot::error::NotFound::with_message())` instead",
188-
since = "0.4.0"
189-
)]
190-
pub fn not_found_message(message: String) -> Self {
191-
Self::from(NotFound::with_message(message))
192-
}
193-
194153
/// Returns the HTTP status code associated with this error.
195154
///
196155
/// This method returns the appropriate HTTP status code that should be
@@ -216,6 +175,7 @@ impl Error {
216175
}
217176

218177
#[must_use]
178+
#[doc(hidden)]
219179
pub fn backtrace(&self) -> &CotBacktrace {
220180
&self.repr.backtrace
221181
}

cot-core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub mod middleware;
2121
pub mod request;
2222
pub mod response;
2323

24-
pub use body::{Body, BodyInner};
24+
pub use body::Body;
2525
pub use error::Error;
2626

2727
/// A type alias for an HTTP status code.

cot-core/src/response/into_response.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,10 @@ impl IntoResponse for Body {
388388
#[cfg(test)]
389389
mod tests {
390390
use bytes::{Bytes, BytesMut};
391-
use http::{self, HeaderMap, HeaderValue};
391+
use http::{self, HeaderMap, HeaderValue, Method};
392392

393393
use super::*;
394-
use crate::error::NotFound;
394+
use crate::error::MethodNotAllowed;
395395
use crate::html::Html;
396396
use crate::response::Response;
397397
use crate::{Body, StatusCode};
@@ -421,13 +421,13 @@ mod tests {
421421

422422
#[cot::test]
423423
async fn test_result_err_into_response() {
424-
let err = Error::from(NotFound::with_message("test"));
424+
let err = Error::from(MethodNotAllowed::new(Method::POST));
425425
let res: Result<&'static str, Error> = Err(err);
426426

427427
let error_result = res.into_response();
428428

429429
assert!(error_result.is_err());
430-
assert!(error_result.err().unwrap().to_string().contains("test"));
430+
assert!(error_result.err().unwrap().to_string().contains("POST"));
431431
}
432432

433433
#[cot::test]

cot/src/error.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
//! including 404 Not Found errors, uncaught panics, and custom error pages.
66
77
pub mod handler;
8+
mod not_found;
89

910
#[doc(inline)]
10-
pub use cot_core::error::{MethodNotAllowed, NotFound, NotFoundKind, UncaughtPanic};
11+
pub use cot_core::error::{MethodNotAllowed, UncaughtPanic};
1112
#[doc(inline)]
1213
pub(crate) use cot_core::error::{backtrace, impl_into_cot_error};
14+
pub use not_found::{Kind as NotFoundKind, NotFound};
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use thiserror::Error;
44

5-
use crate::error::error_impl::impl_into_cot_error;
5+
use crate::error::impl_into_cot_error;
66

77
#[expect(clippy::doc_link_with_quotes, reason = "404 Not Found link")]
88
/// A ["404 Not Found"] error that can be returned by Cot applications.
@@ -72,7 +72,7 @@ impl NotFound {
7272
}
7373

7474
#[must_use]
75-
pub fn router() -> Self {
75+
pub(crate) fn router() -> Self {
7676
Self::with_kind(Kind::FromRouter)
7777
}
7878

cot/src/error_page.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ impl ErrorPageTemplateBuilder {
7272
if let Some(not_found) = error.inner().downcast_ref::<NotFound>() {
7373
use crate::error::NotFoundKind as Kind;
7474
match &not_found.kind {
75-
Kind::Custom { .. } => {
75+
Kind::Custom => {
7676
Self::build_error_data(&mut error_data, error);
7777
}
78-
Kind::WithMessage { 0: message, .. } => {
78+
Kind::WithMessage(message) => {
7979
Self::build_error_data(&mut error_data, error);
8080
error_message = Some(message.clone());
8181
}

0 commit comments

Comments
 (0)