Skip to content

Commit 3e65331

Browse files
authored
Merge pull request #65 from mkantor/render-data-docs
Extend docs for `RenderData`.
2 parents adaf0b9 + 6030a71 commit 3e65331

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/content/mod.rs

+15
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,29 @@ const REQUEST_ROUTE_PROPERTY_NAME: &str = "request-route";
114114
const TARGET_MEDIA_TYPE_PROPERTY_NAME: &str = "target-media-type";
115115

116116
/// Data passed to handlebars templates and executables.
117+
///
118+
/// Fields serialize into kebab-case (e.g. `server_info` becomes `server-info`).
117119
#[derive(Clone, Serialize)]
118120
#[serde(rename_all = "kebab-case")]
119121
pub struct RenderData<ServerInfo: Clone + Serialize> {
122+
/// A hierarchial index of the content. This is serialized with the name
123+
/// `/` (with handlebars escaping this looks like `[/].[foo/].bar`).
120124
#[serde(rename = "/")]
121125
pub index: ContentIndex,
126+
127+
/// Metadata about the server, such as its version.
122128
pub server_info: ServerInfo,
129+
130+
/// The request [`Route`] that caused this content to be rendered, if any.
123131
pub request_route: Option<Route>,
132+
133+
/// The best [`MediaType`] as determined by content negotiation. Rendering
134+
/// must emit content in this media type.
124135
pub target_media_type: Option<MediaType>,
136+
137+
/// An [HTTP `4xx` or `5xx` status code](https://datatracker.ietf.org/doc/html/rfc7231#section-6)
138+
/// indicating that something went wrong. This will be set while rendering
139+
/// content for the `--error-handler-route`.
125140
pub error_code: Option<u16>,
126141
}
127142

0 commit comments

Comments
 (0)