Skip to content

Commit d1c5a9e

Browse files
committed
fix a few docs bugs and export HttpResponseContent
HttpResponseError is made public at the crate root, but it requires implementers also implement HttpResponseContent. HttpResponseContent is *not* public, so implementations of HttpResponseError are constrained to only being types that are covered by blanket impls of HttpResponseContent. i personally don't need to do that, but it makes the docs funky and is probably an error. it's morally similar to a function returning a type which is not public.
1 parent 0b5df8b commit d1c5a9e

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

dropshot/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,11 @@ impl HttpError {
347347
/// If this error does not already have a header map (`self.header_map` is
348348
/// `None`), this method creates one.
349349
///
350-
/// Unlike [`HttpError::set_header`], this method takes `self` by value,
350+
/// Unlike [`HttpError::add_header`], this method takes `self` by value,
351351
/// allowing it to be chained to form an expression that returns an
352352
/// `HttpError`. However, because this takes `self` by value, returning an
353353
/// error for an invalid header name or value will discard the `HttpError`.
354-
/// To avoid this, use [`HttpError::set_header`] instead.
354+
/// To avoid this, use [`HttpError::add_header`] instead.
355355
///
356356
/// # Returns
357357
///

dropshot/src/error_status_code.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::fmt;
1616
/// Alternatively, constants are provided for known error status codes, such as
1717
/// [`ErrorStatusCode::BAD_REQUEST`], [`ErrorStatusCode::NOT_FOUND`],
1818
/// [`ErrorStatusCode::INTERNAL_SERVER_ERROR`], and so on, including those in
19-
/// the IANA HTTP Status Code Registry](
19+
/// the [IANA HTTP Status Code Registry](
2020
/// https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml).
2121
/// Using these constants avoids the fallible conversion from an
2222
/// [`http::StatusCode`].
@@ -425,7 +425,7 @@ impl_status_code_wrapper! {
425425
///
426426
/// Alternatively, constants are provided for known error status codes, such as
427427
/// [`ClientErrorStatusCode::BAD_REQUEST`],
428-
/// [`ClientErrorStatusCode::NOT_FOUND`], including those in the IANA HTTP
428+
/// [`ClientErrorStatusCode::NOT_FOUND`], including those in the [IANA HTTP
429429
/// Status Code Registry](
430430
/// https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml).
431431
/// Using these constants avoids the fallible conversion from an

dropshot/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@ pub use handler::FreeformBody;
909909
pub use handler::HttpCodedResponse;
910910
pub use handler::HttpResponse;
911911
pub use handler::HttpResponseAccepted;
912+
pub use handler::HttpResponseContent;
912913
pub use handler::HttpResponseCreated;
913914
pub use handler::HttpResponseDeleted;
914915
pub use handler::HttpResponseError;

dropshot/src/test_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl ClientTestContext {
243243
}
244244

245245
/// Temporarily configures the client to expect `E`-typed error responses,
246-
/// rather than [`dropshot::HttpError`] error responses.
246+
/// rather than [`dropshot::HttpError`][`crate::HttpError`] error responses.
247247
///
248248
/// `ClientTestContext` expects that all error responses are
249249
/// `dropshot::HttpError`. For testing APIs that return other error types, this

dropshot/tests/fail/bad_endpoint7.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ error[E0277]: the trait bound `Ret: serde::ser::Serialize` is not satisfied
1616
(T0, T1, T2, T3)
1717
(T0, T1, T2, T3, T4)
1818
and $N others
19-
= note: required for `Ret` to implement `dropshot::handler::HttpResponseContent`
19+
= note: required for `Ret` to implement `HttpResponseContent`
2020
note: required by a bound in `HttpResponseOk`
2121
--> src/handler.rs
2222
|
2323
| pub struct HttpResponseOk<T: HttpResponseContent + Send + Sync + 'static>(
2424
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `HttpResponseOk`
2525

26-
error[E0277]: the trait bound `Ret: dropshot::handler::HttpResponseContent` is not satisfied
26+
error[E0277]: the trait bound `Ret: HttpResponseContent` is not satisfied
2727
--> tests/fail/bad_endpoint7.rs:25:23
2828
|
2929
25 | Ok(HttpResponseOk(Ret {
@@ -45,7 +45,7 @@ error[E0277]: the trait bound `Ret: dropshot::handler::HttpResponseContent` is n
4545
(T0, T1, T2, T3)
4646
(T0, T1, T2, T3, T4)
4747
and $N others
48-
= note: required for `Ret` to implement `dropshot::handler::HttpResponseContent`
48+
= note: required for `Ret` to implement `HttpResponseContent`
4949
note: required by a bound in `HttpResponseOk`
5050
--> src/handler.rs
5151
|
@@ -70,7 +70,7 @@ error[E0277]: the trait bound `Ret: serde::ser::Serialize` is not satisfied
7070
(T0, T1, T2, T3)
7171
(T0, T1, T2, T3, T4)
7272
and $N others
73-
= note: required for `Ret` to implement `dropshot::handler::HttpResponseContent`
73+
= note: required for `Ret` to implement `HttpResponseContent`
7474
note: required by a bound in `HttpResponseOk`
7575
--> src/handler.rs
7676
|
@@ -98,7 +98,7 @@ error[E0277]: the trait bound `Ret: serde::ser::Serialize` is not satisfied
9898
(T0, T1, T2, T3)
9999
(T0, T1, T2, T3, T4)
100100
and $N others
101-
= note: required for `Ret` to implement `dropshot::handler::HttpResponseContent`
101+
= note: required for `Ret` to implement `HttpResponseContent`
102102
note: required by a bound in `HttpResponseOk`
103103
--> src/handler.rs
104104
|
@@ -125,7 +125,7 @@ error[E0277]: the trait bound `Ret: serde::ser::Serialize` is not satisfied
125125
(T0, T1, T2, T3)
126126
(T0, T1, T2, T3, T4)
127127
and $N others
128-
= note: required for `Ret` to implement `dropshot::handler::HttpResponseContent`
128+
= note: required for `Ret` to implement `HttpResponseContent`
129129
note: required by a bound in `HttpResponseOk`
130130
--> src/handler.rs
131131
|

dropshot/tests/fail/bad_trait_endpoint7.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: the trait bound `Ret: dropshot::handler::HttpResponseContent` is not satisfied
1+
error[E0277]: the trait bound `Ret: HttpResponseContent` is not satisfied
22
--> tests/fail/bad_trait_endpoint7.rs:41:27
33
|
44
41 | Ok(HttpResponseOk(Ret { x: "Oxide".to_string(), y: 0x1de }))
@@ -16,7 +16,7 @@ error[E0277]: the trait bound `Ret: dropshot::handler::HttpResponseContent` is n
1616
(T0, T1, T2, T3)
1717
(T0, T1, T2, T3, T4)
1818
and $N others
19-
= note: required for `Ret` to implement `dropshot::handler::HttpResponseContent`
19+
= note: required for `Ret` to implement `HttpResponseContent`
2020
note: required by a bound in `dropshot::HttpResponseOk`
2121
--> src/handler.rs
2222
|
@@ -41,7 +41,7 @@ error[E0277]: the trait bound `Ret: serde::ser::Serialize` is not satisfied
4141
(T0, T1, T2, T3)
4242
(T0, T1, T2, T3, T4)
4343
and $N others
44-
= note: required for `Ret` to implement `dropshot::handler::HttpResponseContent`
44+
= note: required for `Ret` to implement `HttpResponseContent`
4545
note: required by a bound in `dropshot::HttpResponseOk`
4646
--> src/handler.rs
4747
|
@@ -66,7 +66,7 @@ error[E0277]: the trait bound `Ret: serde::ser::Serialize` is not satisfied
6666
(T0, T1, T2, T3)
6767
(T0, T1, T2, T3, T4)
6868
and $N others
69-
= note: required for `Ret` to implement `dropshot::handler::HttpResponseContent`
69+
= note: required for `Ret` to implement `HttpResponseContent`
7070
note: required by a bound in `dropshot::HttpResponseOk`
7171
--> src/handler.rs
7272
|
@@ -93,14 +93,14 @@ error[E0277]: the trait bound `Ret: serde::ser::Serialize` is not satisfied
9393
(T0, T1, T2, T3)
9494
(T0, T1, T2, T3, T4)
9595
and $N others
96-
= note: required for `Ret` to implement `dropshot::handler::HttpResponseContent`
96+
= note: required for `Ret` to implement `HttpResponseContent`
9797
note: required by a bound in `dropshot::HttpResponseOk`
9898
--> src/handler.rs
9999
|
100100
| pub struct HttpResponseOk<T: HttpResponseContent + Send + Sync + 'static>(
101101
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `HttpResponseOk`
102102

103-
error[E0277]: the trait bound `Ret: dropshot::handler::HttpResponseContent` is not satisfied
103+
error[E0277]: the trait bound `Ret: HttpResponseContent` is not satisfied
104104
--> tests/fail/bad_trait_endpoint7.rs:28:10
105105
|
106106
28 | ) -> Result<HttpResponseOk<Ret>, HttpError>;
@@ -116,7 +116,7 @@ error[E0277]: the trait bound `Ret: dropshot::handler::HttpResponseContent` is n
116116
(T0, T1, T2, T3)
117117
(T0, T1, T2, T3, T4)
118118
and $N others
119-
= note: required for `Ret` to implement `dropshot::handler::HttpResponseContent`
119+
= note: required for `Ret` to implement `HttpResponseContent`
120120
note: required by a bound in `dropshot::HttpResponseOk`
121121
--> src/handler.rs
122122
|
@@ -141,7 +141,7 @@ error[E0277]: the trait bound `Ret: serde::ser::Serialize` is not satisfied
141141
(T0, T1, T2, T3)
142142
(T0, T1, T2, T3, T4)
143143
and $N others
144-
= note: required for `Ret` to implement `dropshot::handler::HttpResponseContent`
144+
= note: required for `Ret` to implement `HttpResponseContent`
145145
note: required by a bound in `dropshot::HttpResponseOk`
146146
--> src/handler.rs
147147
|

0 commit comments

Comments
 (0)