Skip to content

Commit 2aa2e12

Browse files
Remove unneeded derive(Serialize)
1 parent e070447 commit 2aa2e12

File tree

10 files changed

+35
-67
lines changed

10 files changed

+35
-67
lines changed

src/web/build_details.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ use chrono::{DateTime, Utc};
1616
use futures_util::TryStreamExt;
1717
use rinja::Template;
1818
use semver::Version;
19-
use serde::{Deserialize, Serialize};
19+
use serde::Deserialize;
2020
use std::sync::Arc;
2121

22-
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
22+
#[derive(Debug, Clone, PartialEq, Eq)]
2323
pub(crate) struct BuildDetails {
2424
id: i32,
2525
rustc_version: Option<String>,
@@ -32,7 +32,7 @@ pub(crate) struct BuildDetails {
3232

3333
#[derive(Template)]
3434
#[template(path = "crate/build_details.html")]
35-
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
35+
#[derive(Debug, Clone, PartialEq, Eq)]
3636
struct BuildDetailsPage {
3737
metadata: MetaData,
3838
build_details: BuildDetails,

src/web/builds.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ use constant_time_eq::constant_time_eq;
2929
use http::StatusCode;
3030
use rinja::Template;
3131
use semver::Version;
32-
use serde::Serialize;
33-
use serde_json::json;
3432
use std::sync::Arc;
3533

36-
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
34+
#[derive(Debug, Clone, PartialEq, Eq)]
3735
pub(crate) struct Build {
3836
id: i32,
3937
rustc_version: Option<String>,
@@ -45,7 +43,7 @@ pub(crate) struct Build {
4543

4644
#[derive(Template)]
4745
#[template(path = "crate/builds.html")]
48-
#[derive(Debug, Clone, Serialize)]
46+
#[derive(Debug, Clone)]
4947
struct BuildsPage {
5048
metadata: MetaData,
5149
builds: Vec<Build>,
@@ -235,7 +233,7 @@ pub(crate) async fn build_trigger_rebuild_handler(
235233
.await
236234
.map_err(|e| JsonAxumNope(e.into()))?;
237235

238-
Ok((StatusCode::CREATED, Json(json!({}))))
236+
Ok((StatusCode::CREATED, Json(serde_json::json!({}))))
239237
}
240238

241239
async fn get_builds(

src/web/crate_details.rs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{markdown, match_version, MetaData};
1+
use super::{match_version, MetaData};
22
use crate::registry_api::OwnerKind;
33
use crate::utils::{get_correct_docsrs_style_file, report_error};
44
use crate::web::rustdoc::RustdocHtmlParams;
@@ -27,22 +27,19 @@ use log::warn;
2727
use rinja::Template;
2828
use semver::Version;
2929
use serde::Deserialize;
30-
use serde::{ser::Serializer, Serialize};
3130
use serde_json::Value;
3231
use std::sync::Arc;
3332

3433
// TODO: Add target name and versions
3534

36-
#[derive(Debug, Clone, PartialEq, Serialize)]
35+
#[derive(Debug, Clone, PartialEq)]
3736
pub(crate) struct CrateDetails {
3837
pub(crate) name: String,
3938
pub(crate) version: Version,
4039
pub(crate) description: Option<String>,
4140
pub(crate) owners: Vec<(String, String, OwnerKind)>,
4241
pub(crate) dependencies: Option<Value>,
43-
#[serde(serialize_with = "optional_markdown")]
4442
readme: Option<String>,
45-
#[serde(serialize_with = "optional_markdown")]
4643
rustdoc: Option<String>, // this is description_long in database
4744
release_time: Option<DateTime<Utc>>,
4845
build_status: BuildStatus,
@@ -71,25 +68,15 @@ pub(crate) struct CrateDetails {
7168
pub(crate) release_id: i32,
7269
}
7370

74-
#[derive(Debug, Clone, PartialEq, Serialize)]
71+
#[derive(Debug, Clone, PartialEq)]
7572
struct RepositoryMetadata {
7673
stars: i32,
7774
forks: i32,
7875
issues: i32,
7976
name: Option<String>,
8077
}
8178

82-
fn optional_markdown<S>(markdown: &Option<String>, serializer: S) -> Result<S::Ok, S::Error>
83-
where
84-
S: Serializer,
85-
{
86-
markdown
87-
.as_ref()
88-
.map(|markdown| markdown::render(markdown))
89-
.serialize(serializer)
90-
}
91-
92-
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
79+
#[derive(Debug, Clone, Eq, PartialEq)]
9380
pub(crate) struct Release {
9481
pub id: i32,
9582
pub version: semver::Version,
@@ -425,7 +412,7 @@ pub(crate) async fn releases_for_crate(
425412

426413
#[derive(Template)]
427414
#[template(path = "crate/details.html")]
428-
#[derive(Debug, Clone, PartialEq, Serialize)]
415+
#[derive(Debug, Clone, PartialEq)]
429416
struct CrateDetailsPage {
430417
details: CrateDetails,
431418
csp_nonce: String,
@@ -507,7 +494,7 @@ pub(crate) async fn crate_details_handler(
507494

508495
#[derive(Template)]
509496
#[template(path = "rustdoc/releases.html")]
510-
#[derive(Debug, Clone, PartialEq, Serialize)]
497+
#[derive(Debug, Clone, PartialEq)]
511498
struct ReleaseList {
512499
releases: Vec<Release>,
513500
crate_name: String,
@@ -600,7 +587,7 @@ pub(crate) async fn get_all_releases(
600587
Ok(res.into_response())
601588
}
602589

603-
#[derive(Debug, Clone, PartialEq, Serialize)]
590+
#[derive(Debug, Clone, PartialEq)]
604591
struct ShortMetadata {
605592
name: String,
606593
version: Version,
@@ -617,7 +604,7 @@ impl ShortMetadata {
617604

618605
#[derive(Template)]
619606
#[template(path = "rustdoc/platforms.html")]
620-
#[derive(Debug, Clone, PartialEq, Serialize)]
607+
#[derive(Debug, Clone, PartialEq)]
621608
struct PlatformList {
622609
metadata: ShortMetadata,
623610
inner_path: String,

src/web/features.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ use crate::{
1414
use anyhow::anyhow;
1515
use axum::response::IntoResponse;
1616
use rinja::Template;
17-
use serde::Serialize;
1817
use std::collections::{HashMap, VecDeque};
1918

2019
const DEFAULT_NAME: &str = "default";
2120

2221
#[derive(Template)]
2322
#[template(path = "crate/features.html")]
24-
#[derive(Debug, Clone, Serialize)]
23+
#[derive(Debug, Clone)]
2524
struct FeaturesPage {
2625
metadata: MetaData,
2726
features: Option<Vec<Feature>>,

src/web/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ use error::AxumNope;
4949
use page::TemplateData;
5050
use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS};
5151
use semver::{Version, VersionReq};
52-
use serde::Serialize;
5352
use serde_with::{DeserializeFromStr, SerializeDisplay};
5453
use std::{
5554
borrow::{Borrow, Cow},
@@ -618,7 +617,8 @@ where
618617
}
619618

620619
/// MetaData used in header
621-
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
620+
#[derive(Debug, Clone, PartialEq, Eq)]
621+
#[cfg_attr(test, derive(serde::Serialize))]
622622
pub(crate) struct MetaData {
623623
pub(crate) name: String,
624624
/// The exact version of the release being shown.
@@ -721,13 +721,12 @@ impl MetaData {
721721

722722
#[derive(Template)]
723723
#[template(path = "error.html")]
724-
#[derive(Debug, Clone, PartialEq, Serialize)]
724+
#[derive(Debug, Clone, PartialEq)]
725725
pub(crate) struct AxumErrorPage {
726726
/// The title of the page
727727
pub title: &'static str,
728728
/// The error message, displayed as a description
729729
pub message: Cow<'static, str>,
730-
#[serde(skip)]
731730
pub status: StatusCode,
732731
pub csp_nonce: String,
733732
}

src/web/releases.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ async fn get_search_results(
301301

302302
#[derive(Template)]
303303
#[template(path = "core/home.html")]
304-
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
304+
#[derive(Debug, Clone, PartialEq, Eq)]
305305
struct HomePage {
306306
recent_releases: Vec<Release>,
307307
csp_nonce: String,
@@ -330,7 +330,7 @@ pub(crate) async fn home_page(mut conn: DbConnection) -> AxumResult<impl IntoRes
330330

331331
#[derive(Template)]
332332
#[template(path = "releases/feed.xml")]
333-
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
333+
#[derive(Debug, Clone, PartialEq, Eq)]
334334
struct ReleaseFeed {
335335
recent_releases: Vec<Release>,
336336
csp_nonce: String,
@@ -352,7 +352,7 @@ pub(crate) async fn releases_feed_handler(mut conn: DbConnection) -> AxumResult<
352352

353353
#[derive(Template)]
354354
#[template(path = "releases/releases.html")]
355-
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
355+
#[derive(Debug, Clone, PartialEq, Eq)]
356356
struct ViewReleases {
357357
releases: Vec<Release>,
358358
description: String,
@@ -372,8 +372,7 @@ impl ViewReleases {
372372
}
373373
}
374374

375-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize)]
376-
#[serde(rename_all = "kebab-case")]
375+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
377376
pub(crate) enum ReleaseType {
378377
Recent,
379378
Stars,
@@ -496,7 +495,7 @@ pub(crate) async fn owner_handler(Path(owner): Path<String>) -> AxumResult<impl
496495

497496
#[derive(Template)]
498497
#[template(path = "releases/search_results.html")]
499-
#[derive(Debug, Clone, PartialEq, Serialize)]
498+
#[derive(Debug, Clone, PartialEq)]
500499
pub(super) struct Search {
501500
pub(super) title: String,
502501
pub(super) releases: Vec<Release>,
@@ -506,7 +505,6 @@ pub(super) struct Search {
506505
pub(super) next_page_link: Option<String>,
507506
/// This should always be `ReleaseType::Search`
508507
pub(super) release_type: ReleaseType,
509-
#[serde(skip)]
510508
pub(super) status: http::StatusCode,
511509
pub(super) csp_nonce: String,
512510
}
@@ -732,7 +730,7 @@ pub(crate) async fn search_handler(
732730

733731
#[derive(Template)]
734732
#[template(path = "releases/activity.html")]
735-
#[derive(Debug, Clone, PartialEq, Serialize)]
733+
#[derive(Debug, Clone, PartialEq)]
736734
struct ReleaseActivity {
737735
description: &'static str,
738736
dates: Vec<String>,

src/web/routes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ pub(super) fn build_axum_routes() -> AxumRouter {
290290
get_internal(|| async {
291291
#[derive(Template)]
292292
#[template(path = "storage-change-detection.html")]
293-
#[derive(Debug, Clone, serde::Serialize)]
293+
#[derive(Debug, Clone)]
294294
struct StorageChangeDetection {
295295
csp_nonce: String,
296296
}

src/web/rustdoc.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use axum::{
2828
use lol_html::errors::RewritingError;
2929
use once_cell::sync::Lazy;
3030
use semver::Version;
31-
use serde::{Deserialize, Serialize};
31+
use serde::Deserialize;
3232
use std::{
3333
collections::{BTreeMap, HashMap},
3434
sync::Arc,
@@ -257,12 +257,10 @@ pub(crate) async fn rustdoc_redirector_handler(
257257
}
258258
}
259259

260-
#[derive(Debug, Clone, Serialize)]
260+
#[derive(Debug, Clone)]
261261
pub struct RustdocPage {
262262
pub latest_path: String,
263263
pub permalink_path: String,
264-
pub latest_version: String,
265-
pub target: String,
266264
pub inner_path: String,
267265
// true if we are displaying the latest version of the crate, regardless
268266
// of whether the URL specifies a version number or the string "latest."
@@ -604,12 +602,6 @@ pub(crate) async fn rustdoc_html_server_handler(
604602
.recently_accessed_releases
605603
.record(krate.crate_id, krate.release_id, target);
606604

607-
let target = if target.is_empty() {
608-
String::new()
609-
} else {
610-
format!("{target}/")
611-
};
612-
613605
// Build the page of documentation,
614606
templates
615607
.render_in_threadpool({
@@ -619,8 +611,6 @@ pub(crate) async fn rustdoc_html_server_handler(
619611
Ok(RustdocPage {
620612
latest_path,
621613
permalink_path,
622-
latest_version: latest_version.to_string(),
623-
target,
624614
inner_path,
625615
is_latest_version,
626616
is_latest_url: params.version.is_latest(),

src/web/sitemap.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ use axum::{extract::Extension, http::StatusCode, response::IntoResponse};
1515
use chrono::{TimeZone, Utc};
1616
use futures_util::stream::TryStreamExt;
1717
use rinja::Template;
18-
use serde::Serialize;
1918
use std::sync::Arc;
2019

2120
/// sitemap index
2221
#[derive(Template)]
2322
#[template(path = "core/sitemapindex.xml")]
24-
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
23+
#[derive(Debug, Clone, PartialEq, Eq)]
2524
struct SitemapIndexXml {
2625
sitemaps: Vec<char>,
2726
csp_nonce: String,
@@ -41,7 +40,7 @@ pub(crate) async fn sitemapindex_handler() -> impl IntoResponse {
4140
}
4241
}
4342

44-
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
43+
#[derive(Debug, Clone, PartialEq, Eq)]
4544
struct SitemapRow {
4645
crate_name: String,
4746
last_modified: String,
@@ -51,7 +50,7 @@ struct SitemapRow {
5150
/// The sitemap
5251
#[derive(Template)]
5352
#[template(path = "core/sitemap.xml")]
54-
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
53+
#[derive(Debug, Clone, PartialEq, Eq)]
5554
struct SitemapXml {
5655
releases: Vec<SitemapRow>,
5756
csp_nonce: String,
@@ -112,7 +111,7 @@ pub(crate) async fn sitemap_handler(
112111

113112
#[derive(Template)]
114113
#[template(path = "core/about/builds.html")]
115-
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
114+
#[derive(Debug, Clone, PartialEq, Eq)]
116115
struct AboutBuilds {
117116
/// The current version of rustc that docs.rs is using to build crates
118117
rustc_version: Option<String>,

0 commit comments

Comments
 (0)