mcapi 0.3.0

Unified async Rust client for the Minecraft ecosystem (Mojang, Modrinth, CurseForge, Yggdrasil, Blessing Skin, Loaders, BMCLAPI, and Java Runtimes)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
use jiff::Timestamp;
use serde::{Deserialize, Serialize};
use url::Url;

/// Modrinth project kind.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum ProjectType {
    Mod,
    Modpack,
    Resourcepack,
    Shader,
    Plugin,
    Datapack,
    #[serde(other)]
    Unknown,
}

impl ProjectType {
    /// Returns the lowercase wire value expected by Modrinth APIs and facets.
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            ProjectType::Mod => "mod",
            ProjectType::Modpack => "modpack",
            ProjectType::Resourcepack => "resourcepack",
            ProjectType::Shader => "shader",
            ProjectType::Plugin => "plugin",
            ProjectType::Datapack => "datapack",
            ProjectType::Unknown => "unknown",
        }
    }
}

/// Publication status of a Modrinth project.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum ProjectStatus {
    Approved,
    Archived,
    Rejected,
    Draft,
    Unlisted,
    Processing,
    Withheld,
    Scheduled,
    Private,
    #[serde(other)]
    Unknown,
}

/// Requested status when submitting or creating a project.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum RequestedStatus {
    Approved,
    Archived,
    Unlisted,
    Private,
    Draft,
    #[serde(other)]
    Unknown,
}

/// Client/server side compatibility level.
#[non_exhaustive]
#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum SideSupport {
    Required,
    Optional,
    Unsupported,
    #[serde(other)]
    Unknown,
}

impl SideSupport {
    /// Returns the lowercase wire value (`"required"`, `"optional"`, `"unsupported"`, or `"unknown"`).
    #[must_use]
    pub const fn as_str(self) -> &'static str {
        match self {
            SideSupport::Required => "required",
            SideSupport::Optional => "optional",
            SideSupport::Unsupported => "unsupported",
            SideSupport::Unknown => "unknown",
        }
    }
}

/// Donation link attached to a project.
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
pub struct DonationLink {
    pub id: String,
    pub platform: String,
    pub url: Url,
}

/// Gallery image attached to a project.
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
pub struct GalleryImage {
    pub url: Url,
    pub featured: bool,
    #[serde(default)]
    pub title: Option<String>,
    #[serde(default)]
    pub description: Option<String>,
    pub created: Timestamp,
    #[serde(default)]
    pub ordering: Option<i32>,
}

/// License reference embedded in [`Project`].
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
pub struct LicenseRef {
    pub id: String,
    pub name: String,
    #[serde(default)]
    pub url: Option<Url>,
}

/// Moderation notice attached to a Modrinth [`Project`].
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
pub struct ModeratorMessage {
    pub message: String,
    #[serde(default)]
    pub body: Option<String>,
}

/// Complete Modrinth project object returned by `/v2/project/{id|slug}`.
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
pub struct Project {
    pub id: String,
    pub slug: String,
    pub project_type: ProjectType,
    pub team: String,
    pub title: String,
    pub description: String,
    pub body: String,
    #[serde(default)]
    pub body_url: Option<Url>,
    pub published: Timestamp,
    pub updated: Timestamp,
    #[serde(default)]
    pub approved: Option<Timestamp>,
    #[serde(default)]
    pub queued: Option<Timestamp>,
    pub status: ProjectStatus,
    #[serde(default)]
    pub requested_status: Option<RequestedStatus>,
    #[serde(default)]
    pub moderator_message: Option<ModeratorMessage>,
    pub license: LicenseRef,
    pub client_side: SideSupport,
    pub server_side: SideSupport,
    pub downloads: u64,
    pub followers: u64,
    #[serde(default)]
    pub categories: Vec<String>,
    #[serde(default)]
    pub additional_categories: Vec<String>,
    #[serde(default)]
    pub game_versions: Vec<String>,
    #[serde(default)]
    pub loaders: Vec<String>,
    #[serde(default)]
    pub versions: Vec<String>,
    #[serde(default)]
    pub icon_url: Option<Url>,
    #[serde(default)]
    pub issues_url: Option<Url>,
    #[serde(default)]
    pub source_url: Option<Url>,
    #[serde(default)]
    pub wiki_url: Option<Url>,
    #[serde(default)]
    pub discord_url: Option<Url>,
    #[serde(default)]
    pub donation_urls: Vec<DonationLink>,
    #[serde(default)]
    pub gallery: Vec<GalleryImage>,
    #[serde(default)]
    pub color: Option<u32>,
    #[serde(default)]
    pub thread_id: Option<String>,
    #[serde(default)]
    pub monetization_status: Option<String>,
}

/// Response returned by `GET /v2/project/{id|slug}/check`.
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
pub struct ProjectValidity {
    pub id: String,
}

/// Response returned by `GET /v2/project/{id|slug}/dependencies`.
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
pub struct ProjectDependencies {
    pub projects: Vec<Project>,
    pub versions: Vec<super::Version>,
}

/// In-memory file payload for multipart upload endpoints (project creation icon and version files).
#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct UploadFile {
    pub file_name: String,
    pub mime_type: String,
    pub bytes: Vec<u8>,
}

#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
impl UploadFile {
    /// Creates an in-memory multipart upload payload with filename, MIME type, and raw bytes.
    #[must_use]
    pub fn new(file_name: impl Into<String>, mime_type: impl Into<String>, bytes: Vec<u8>) -> Self {
        Self {
            file_name: file_name.into(),
            mime_type: mime_type.into(),
            bytes,
        }
    }
}

/// Payload for creating a new project via `POST /v2/project`.
#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
#[non_exhaustive]
#[derive(Clone, Debug, Serialize, Eq, PartialEq)]
pub struct CreateProjectRequest {
    pub slug: String,
    pub title: String,
    pub description: String,
    pub categories: Vec<String>,
    pub client_side: SideSupport,
    pub server_side: SideSupport,
    pub body: String,
    pub project_type: ProjectType,
    pub license_id: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub license_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub issues_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub wiki_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub discord_url: Option<String>,
    #[serde(default)]
    pub is_draft: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub initial_versions: Option<Vec<serde_json::Value>>,
}

#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
impl CreateProjectRequest {
    /// Creates a project creation payload with required metadata.
    ///
    /// Defaults `categories` to empty, `client_side` and `server_side` to
    /// [`SideSupport::Optional`], and `is_draft` to `false`.
    #[must_use]
    pub fn new(
        slug: impl Into<String>,
        title: impl Into<String>,
        description: impl Into<String>,
        body: impl Into<String>,
        project_type: ProjectType,
        license_id: impl Into<String>,
    ) -> Self {
        Self {
            slug: slug.into(),
            title: title.into(),
            description: description.into(),
            categories: Vec::new(),
            client_side: SideSupport::Optional,
            server_side: SideSupport::Optional,
            body: body.into(),
            project_type,
            license_id: license_id.into(),
            license_url: None,
            issues_url: None,
            source_url: None,
            wiki_url: None,
            discord_url: None,
            is_draft: false,
            initial_versions: None,
        }
    }

    /// Sets the primary category slugs.
    #[must_use]
    pub fn categories(mut self, categories: impl IntoIterator<Item = impl Into<String>>) -> Self {
        self.categories = categories.into_iter().map(Into::into).collect();
        self
    }

    /// Sets client-side environment compatibility.
    #[must_use]
    pub fn client_side(mut self, client_side: SideSupport) -> Self {
        self.client_side = client_side;
        self
    }

    /// Sets server-side environment compatibility.
    #[must_use]
    pub fn server_side(mut self, server_side: SideSupport) -> Self {
        self.server_side = server_side;
        self
    }

    /// Sets a custom license URL when using a non-SPDX license.
    #[must_use]
    pub fn license_url(mut self, url: impl Into<String>) -> Self {
        self.license_url = Some(url.into());
        self
    }

    /// Sets the issue tracker URL.
    #[must_use]
    pub fn issues_url(mut self, url: impl Into<String>) -> Self {
        self.issues_url = Some(url.into());
        self
    }

    /// Sets the source repository URL.
    #[must_use]
    pub fn source_url(mut self, url: impl Into<String>) -> Self {
        self.source_url = Some(url.into());
        self
    }

    /// Sets the project wiki URL.
    #[must_use]
    pub fn wiki_url(mut self, url: impl Into<String>) -> Self {
        self.wiki_url = Some(url.into());
        self
    }

    /// Sets the Discord invite URL.
    #[must_use]
    pub fn discord_url(mut self, url: impl Into<String>) -> Self {
        self.discord_url = Some(url.into());
        self
    }

    /// Sets whether the project starts as an unpublished draft.
    #[must_use]
    pub fn is_draft(mut self, is_draft: bool) -> Self {
        self.is_draft = is_draft;
        self
    }

    /// Attaches optional raw initial version payloads.
    #[must_use]
    pub fn initial_versions(mut self, initial_versions: Vec<serde_json::Value>) -> Self {
        self.initial_versions = Some(initial_versions);
        self
    }
}

/// Patch payload for `PATCH /v2/project/{id|slug}`.
#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
#[non_exhaustive]
#[derive(Clone, Debug, Default, Serialize, Eq, PartialEq)]
pub struct ModifyProjectRequest {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub slug: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub categories: Option<Vec<String>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub additional_categories: Option<Vec<String>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_side: Option<SideSupport>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub server_side: Option<SideSupport>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub body: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<RequestedStatus>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub license_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub license_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub issues_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub wiki_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub discord_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub donation_urls: Option<Vec<DonationLink>>,
}

#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
impl ModifyProjectRequest {
    /// Creates an empty [`ModifyProjectRequest`] (no fields modified).
    #[must_use]
    pub fn new() -> Self {
        Self::default()
    }

    /// Updates the project URL slug.
    #[must_use]
    pub fn slug(mut self, slug: impl Into<String>) -> Self {
        self.slug = Some(slug.into());
        self
    }

    /// Updates the project display title.
    #[must_use]
    pub fn title(mut self, title: impl Into<String>) -> Self {
        self.title = Some(title.into());
        self
    }

    /// Updates the short summary description.
    #[must_use]
    pub fn description(mut self, description: impl Into<String>) -> Self {
        self.description = Some(description.into());
        self
    }

    /// Replaces the primary category slugs.
    #[must_use]
    pub fn categories(mut self, categories: impl IntoIterator<Item = impl Into<String>>) -> Self {
        self.categories = Some(categories.into_iter().map(Into::into).collect());
        self
    }

    /// Replaces the additional category slugs.
    #[must_use]
    pub fn additional_categories(
        mut self,
        categories: impl IntoIterator<Item = impl Into<String>>,
    ) -> Self {
        self.additional_categories = Some(categories.into_iter().map(Into::into).collect());
        self
    }

    /// Updates client-side environment compatibility.
    #[must_use]
    pub fn client_side(mut self, client_side: SideSupport) -> Self {
        self.client_side = Some(client_side);
        self
    }

    /// Updates server-side environment compatibility.
    #[must_use]
    pub fn server_side(mut self, server_side: SideSupport) -> Self {
        self.server_side = Some(server_side);
        self
    }

    /// Updates the long-form markdown body.
    #[must_use]
    pub fn body(mut self, body: impl Into<String>) -> Self {
        self.body = Some(body.into());
        self
    }

    /// Updates the requested project publication status.
    #[must_use]
    pub fn status(mut self, status: RequestedStatus) -> Self {
        self.status = Some(status);
        self
    }

    /// Updates the SPDX or custom license ID.
    #[must_use]
    pub fn license_id(mut self, license_id: impl Into<String>) -> Self {
        self.license_id = Some(license_id.into());
        self
    }

    /// Updates the custom license URL.
    #[must_use]
    pub fn license_url(mut self, url: impl Into<String>) -> Self {
        self.license_url = Some(url.into());
        self
    }

    /// Updates the issue tracker URL.
    #[must_use]
    pub fn issues_url(mut self, url: impl Into<String>) -> Self {
        self.issues_url = Some(url.into());
        self
    }

    /// Updates the source repository URL.
    #[must_use]
    pub fn source_url(mut self, url: impl Into<String>) -> Self {
        self.source_url = Some(url.into());
        self
    }

    /// Updates the project wiki URL.
    #[must_use]
    pub fn wiki_url(mut self, url: impl Into<String>) -> Self {
        self.wiki_url = Some(url.into());
        self
    }

    /// Updates the Discord invite URL.
    #[must_use]
    pub fn discord_url(mut self, url: impl Into<String>) -> Self {
        self.discord_url = Some(url.into());
        self
    }

    /// Replaces the project's donation links.
    #[must_use]
    pub fn donation_urls(mut self, donation_urls: Vec<DonationLink>) -> Self {
        self.donation_urls = Some(donation_urls);
        self
    }
}

/// Bulk patch payload for `PATCH /v2/projects`.
#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
#[non_exhaustive]
#[derive(Clone, Debug, Default, Serialize, Eq, PartialEq)]
pub struct BulkEditProjectsRequest {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub categories: Option<Vec<String>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub add_categories: Option<Vec<String>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remove_categories: Option<Vec<String>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub donation_urls: Option<Vec<DonationLink>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub issues_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub wiki_url: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub discord_url: Option<String>,
}

#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
impl BulkEditProjectsRequest {
    /// Creates an empty [`BulkEditProjectsRequest`].
    #[must_use]
    pub fn new() -> Self {
        Self::default()
    }

    /// Replaces the categories across all targeted projects.
    #[must_use]
    pub fn categories(mut self, categories: impl IntoIterator<Item = impl Into<String>>) -> Self {
        self.categories = Some(categories.into_iter().map(Into::into).collect());
        self
    }

    /// Adds categories to all targeted projects.
    #[must_use]
    pub fn add_categories(
        mut self,
        categories: impl IntoIterator<Item = impl Into<String>>,
    ) -> Self {
        self.add_categories = Some(categories.into_iter().map(Into::into).collect());
        self
    }

    /// Removes categories from all targeted projects.
    #[must_use]
    pub fn remove_categories(
        mut self,
        categories: impl IntoIterator<Item = impl Into<String>>,
    ) -> Self {
        self.remove_categories = Some(categories.into_iter().map(Into::into).collect());
        self
    }

    /// Replaces donation links across all targeted projects.
    #[must_use]
    pub fn donation_urls(mut self, donation_urls: Vec<DonationLink>) -> Self {
        self.donation_urls = Some(donation_urls);
        self
    }

    /// Sets the issue tracker URL across all targeted projects.
    #[must_use]
    pub fn issues_url(mut self, url: impl Into<String>) -> Self {
        self.issues_url = Some(url.into());
        self
    }

    /// Sets the source repository URL across all targeted projects.
    #[must_use]
    pub fn source_url(mut self, url: impl Into<String>) -> Self {
        self.source_url = Some(url.into());
        self
    }

    /// Sets the wiki URL across all targeted projects.
    #[must_use]
    pub fn wiki_url(mut self, url: impl Into<String>) -> Self {
        self.wiki_url = Some(url.into());
        self
    }

    /// Sets the Discord invite URL across all targeted projects.
    #[must_use]
    pub fn discord_url(mut self, url: impl Into<String>) -> Self {
        self.discord_url = Some(url.into());
        self
    }
}

/// Query parameters for `POST /v2/project/{id|slug}/gallery`.
#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
#[non_exhaustive]
#[derive(Clone, Debug, Serialize, Eq, PartialEq)]
pub struct AddGalleryImageRequest {
    pub ext: String,
    pub featured: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ordering: Option<i32>,
}

#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
impl AddGalleryImageRequest {
    /// Creates an upload descriptor for a gallery image with file extension `ext` and featured flag.
    #[must_use]
    pub fn new(ext: impl Into<String>, featured: bool) -> Self {
        Self {
            ext: ext.into(),
            featured,
            title: None,
            description: None,
            ordering: None,
        }
    }

    /// Sets the optional display title for the gallery image.
    #[must_use]
    pub fn title(mut self, title: impl Into<String>) -> Self {
        self.title = Some(title.into());
        self
    }

    /// Sets the optional caption/description for the gallery image.
    #[must_use]
    pub fn description(mut self, description: impl Into<String>) -> Self {
        self.description = Some(description.into());
        self
    }

    /// Sets the display ordering index for the gallery image.
    #[must_use]
    pub fn ordering(mut self, ordering: i32) -> Self {
        self.ordering = Some(ordering);
        self
    }
}

/// Query parameters for `PATCH /v2/project/{id|slug}/gallery`.
#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
#[non_exhaustive]
#[derive(Clone, Debug, Serialize, Eq, PartialEq)]
pub struct ModifyGalleryImageRequest {
    pub url: Url,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub featured: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ordering: Option<i32>,
}

#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
impl ModifyGalleryImageRequest {
    /// Creates a gallery modification request targeting the existing image `url`.
    #[must_use]
    pub fn new(url: Url) -> Self {
        Self {
            url,
            featured: None,
            title: None,
            description: None,
            ordering: None,
        }
    }

    /// Sets whether the image is featured on the project summary.
    #[must_use]
    pub fn featured(mut self, featured: bool) -> Self {
        self.featured = Some(featured);
        self
    }

    /// Updates the display title for the gallery image.
    #[must_use]
    pub fn title(mut self, title: impl Into<String>) -> Self {
        self.title = Some(title.into());
        self
    }

    /// Updates the caption/description for the gallery image.
    #[must_use]
    pub fn description(mut self, description: impl Into<String>) -> Self {
        self.description = Some(description.into());
        self
    }

    /// Updates the display ordering index for the gallery image.
    #[must_use]
    pub fn ordering(mut self, ordering: i32) -> Self {
        self.ordering = Some(ordering);
        self
    }
}

/// Request payload for `POST /v2/project/{id|slug}/schedule`.
#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
#[non_exhaustive]
#[derive(Clone, Debug, Serialize, Eq, PartialEq)]
pub struct ScheduleProjectRequest {
    pub time: Timestamp,
    pub requested_status: RequestedStatus,
}

#[cfg(feature = "modrinth-write")]
#[cfg_attr(docsrs, doc(cfg(feature = "modrinth-write")))]
impl ScheduleProjectRequest {
    /// Creates a scheduled status transition request at `time`.
    #[must_use]
    pub fn new(time: Timestamp, requested_status: RequestedStatus) -> Self {
        Self {
            time,
            requested_status,
        }
    }
}