mine_data_structs 1.0.9

Minecraft data structures
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
#![allow(rustdoc::bare_urls)]
//! Module containing data structs to operate with Rinth API <3.
//!
//! Even tho this crate only contains de data structures (and some QoL
//! functions) of the API the requests and parameters are also explained in each
//! struct.
//!
//! Be aware that Rinth API is in constant change, right now v2 is the
//! production server but at this time they are already working in v3. In any
//! case if something get deprecated or new structs are available/needed I'm
//! sure you already know... PR !!!!!!

// TODO:
// Project type allowed values are: mod, modpack, resourcepack, shader.
// This looks like an enum right ?

use std::collections::HashMap;
use std::path::{Path, PathBuf};

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "serde")]
use std::fs::read_to_string;
// ===================
// |Projects section |
// ===================

/// Struct which contains all the "hits" for a given search.
///
/// This struct is the one Modrinth will return when asked for
/// projects.
///
/// # API Request
/// ## Search projects
///
/// GET https://api.modrinth.com/v2/search
///
/// ### Parameters
/// - Query parameters
///   - query:  string
///   - facets: string
///  
///   - index:  string  *Allowed values: relevance downloads follows newest
///     updated*
///   - offset: integer
///   - limit:  integer
///
/// # More info
/// `https://docs.modrinth.com/api/operations/searchprojects/`
///
/// # Compatibility
///
/// "Deprecated values below. WILL BE REMOVED V3!"
/// <https://github.com/modrinth/code/blob/b9d90aa6356c88c8d661c04ab84194cf08ea0198/apps/labrinth/src/models/v3/projects.rs>
///
/// Facets, filters and versions seems to be "deprecated" in V3 ??
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct SearchProjects {
    pub hits: Box<[Hit]>,
    pub offset: u32,
    pub limit: u32,
    pub total_hits: u64,
}

impl SearchProjects {
    pub fn len(&self) -> usize {
        self.hits.len()
    }

    pub fn is_empty(&self) -> bool {
        self.len() == 0
    }
}

/// Every hit of [`SearchProjects`] struct.
///
/// This struct contains the information of each hit.
///
/// # Missing fields
///
/// Want them ? PR !!
/// - `thread_id`
/// - `monetization_status`
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct Hit {
    /// The slug of a project, used for vanity URLs.
    /// Regex: ^[\w!@$()`.+,"\-']{3,64}$
    pub slug: String,
    pub title: String,
    pub description: String,
    pub categories: Box<String>,
    /// Allowed values: required optional unsupported unknown
    pub client_side: String,
    /// Allowed values: required optional unsupported unknown
    pub server_side: String,
    /// Allowed values: mod modpack resourcepack shader
    pub project_type: String,
    pub downloads: usize,
    pub icon_url: Option<String>,
    pub color: Option<usize>,
    pub project_id: String,
    pub author: String,
    pub display_categories: Box<[String]>,
    pub versions: Box<[String]>,
    pub follows: usize,
    /// format: ISO-8601
    pub date_created: String,
    /// format: ISO-8601
    pub date_modified: String,
    /// The latest version of minecraft that this project supports.
    pub latest_version: Option<String>,
    pub license: String,
    /// All gallery images attached to the project (urls)
    pub gallery: Box<[String]>,
}

pub enum Attributes {
    Loader,
    Name,
    VersionType,
}

/// A project returned from the API
///
/// # API Request
/// ## Get a project
///
/// GET https://api.modrinth.com/v2/project/{id | slug}
///
/// ### Parameters
/// - id|slug String (Required)
///
/// This type is also usable when requesting searches for rinth api
///
/// # Missing fields
/// - `issues_url`
/// - `source_url`
/// - `wiki_url`
/// - `discord_url`
/// - `donation_url`
/// - `color`
/// - `thread_id`
/// - `monetization_status`
/// - `moderator message`
/// - `approved`
/// - `queued`
/// - `license`
/// - `gallery`
///
/// Want any of them ? PR !!!
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct RinthProject {
    /// The slug of a project, used for vanity URLs.
    /// Regex: ^[\w!@$()`.+,"\-']{3,64}$
    pub slug: String,
    pub title: String,
    pub description: String,
    pub categories: Box<[String]>,
    /// Allowed values: required optional unsupported unknown
    pub client_side: String,
    /// Allowed values: required optional unsupported unknown
    pub server_side: String,
    pub body: String,
    /// Allowed values: approved archived rejected draft unlisted processing
    /// withheld scheduled private unknown
    pub status: String,
    /// Allowed values: approved archived unlisted private draft
    pub requested_status: Option<String>,
    /// A list of categories which are searchable but non-primary.
    pub additional_categories: Box<[String]>,
    /// Allowed values: mod modpack resourcepack shader
    pub project_type: String,
    pub downloads: u32,
    pub icon_url: Option<String>,
    pub id: String,
    pub team: String,
    /// The link to the long description of the project. Always null, only kept
    /// for legacy compatibility.
    pub body_url: Option<String>,
    /// format: ISO-8601
    pub published: String,
    /// format: ISO-8601
    pub updated: String,
    pub followers: u32,
    /// A list of the version IDs of the project (will never be empty unless
    /// draft status)
    pub versions: Box<[String]>,
    /// A list of all of the game versions supported by the project
    pub game_versions: Box<[String]>,
    pub loaders: Box<[String]>,
}

/// Fancy name for array of [`RinthProject`]
///
/// This type will be used when asking for multiple projects.
///
/// # API Request
///
/// ## Get multiple projects
///
/// GET https://api.modrinth.com/v2/projects
///
/// ### Parameters
/// - Query parameters
///   - ids String array (Required)
///
/// ## Get a list of random projects
///
/// GET https://api.modrinth.com/v2/projects_random
///
/// ### Parameters
/// - count int (Required)
///
/// # More info:
///
/// <https://docs.modrinth.com/api/operations/getprojects/>
pub type RinthProjects = Box<[RinthProject]>;

/// Struct used when getting all of a project's dependencies.
///
/// This is from v2 API so maybe its removed in the future.
///
/// # API Requests
/// ## Get all of a project's dependencies
///
/// GET https://api.modrinth.com/v2/project/{id|slug}/dependencies
///
/// ### Parameters
/// - id|slug String (Required)
///
/// # More info
/// <https://github.com/modrinth/code/blob/main/apps/labrinth/src/routes/v2/projects.rs>
pub struct Dependencies {
    pub projects: Box<[RinthProject]>,
    pub versions: Box<[DependencyInfo]>,
}

/// A specific version of a project. This is from v2 API so maybe its removed in
/// a future.
///
/// Used in [`Dependencies`] [`ProjectVersions`]
///
/// # API Requests
/// ## Get a version
///
/// GET https://api.modrinth.com/v2/version/{id}
///
/// ### Parameters
/// - id String (Required)
///
/// # Latest version of a project from a hash, loader(s), and game version(s)
///
/// POST https://api.modrinth.com/v2/version_file/{hash}/update
///
/// ### Parameters
/// - Path Parameters
///   - hash String (Required)
///
/// - Query Parameters
///   - algorithm String (Required) Allowed values: sha1 sha512
///
/// ### Request Body
/// - loaders String array (Required)
/// - game_versions String array (Required) example: ["1.18", "1.18.1", ...]
///
/// # Missing fields
/// - `requested_status`
///
/// # Used in
/// <https://docs.modrinth.com/api/operations/getlatestversionfromhash/>
/// <https://docs.modrinth.com/api/operations/getversion/>
///
/// # More info
/// <https://github.com/modrinth/code/blob/main/apps/labrinth/src/models/v2/projects.rs>
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
pub struct DependencyInfo {
    pub name: String,
    pub version_number: String,

    pub dependencies: Box<[Dependency]>,

    pub game_versions: Box<[String]>,
    // Allowed values: release beta alpha
    pub version_type: String,

    /// A list of loaders this project supports (has a newtype struct)
    pub loaders: Box<[String]>,
    pub featured: bool,
    // Allowed values: listed archived draft unlisted scheduled unknown
    pub status: String,

    pub id: String,
    pub project_id: String,
    pub author_id: String,
    /// format: ISO-8601
    pub date_published: String,
    pub downloads: u32,
    pub changelog: String,
    pub changelog_url: Option<String>,
    /// A list of files available for download for this version.
    pub files: Box<[DependencyFiles]>,
}

/// A dendency which describes what versions are required, break support, or are
/// optional to the version's functionality
///
/// Go look [`DependencyInfo`] for more information, this struct is used there.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Dependency {
    pub version_id: Option<String>,
    pub project_id: Option<String>,
    pub file_name: Option<String>,
    pub dependency_type: String,
}

/// A single project file, with a url for the file and the file's hash.
///
/// Do you think the description isn't good enough ? I copied it from
/// the original repo: <https://github.com/modrinth/code/blob/main/apps/labrinth/src/models/v3/projects.rs>
///
/// Go look [`DependencyInfo`] for more information, this struct is used there.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct DependencyFiles {
    pub hashes: std::collections::HashMap<String, String>,
    pub url: String,
    pub filename: String,
    pub primary: bool,
    pub size: u32,
    /// Allowed values: required-resource-pack optional-resource-pack
    pub file_type: Option<String>,
}

// ===================
// |Versions section |
// ===================

/// Struct which is used when retrieving mods.
///
/// This is from v2 API so maybe its removed in the future.
///
/// This struct is also compatible with the following requests:
///
/// # API Requests
/// ## 1. List project's versions
///
/// GET https://api.modrinth.com/v2/project/{id|slug}/version
///
/// ### Parameters
/// - Path Parameters
///   - id|slug String (Required)
///
/// - Query Parameters
///   - loaders: String array
///   - game_versions: String array
///   - featured: bool
///
///
/// ## 2. Get multiple versions
///
/// GET https://api.modrinth.com/v2/versions
///
/// ### Parameters
/// - ids String array.
///
/// ## 3. Get version from hash
///
/// GET https://api.modrinth.com/v2/version_file/{hash}
///
/// ### Parameters
/// - hash string (Required)
///
/// # More info
/// <https://docs.modrinth.com/api/operations/getprojectversions/>
/// <https://docs.modrinth.com/api/operations/getversions/>
pub struct ProjectVersions {
    pub versions: Box<[DependencyInfo]>,
}

/// Fancy name for `HashMap<String,DependencyInfo>`.
///
/// # API Requests
/// ## Get versions from hashses
///
/// GET https://api.modrinth.com/v2/version_files
///
/// ### Parameters
/// - hashes String array (Required)
/// - algorithm String *Allowed values: sha1 sha512*
///
/// # Used in
/// <https://docs.modrinth.com/api/operations/versionsfromhashes/>
pub type DependencyInfosH = HashMap<String, DependencyInfo>;

// TODO: https://docs.modrinth.com/api/operations/getlatestversionsfromhashes/

// DEPRECATING THIS !!
// VVVVVVVVVVVVVVVVV

// This struct represent the `dependencies` object from a
// `https://api.modrinth.com/v2/project/{id|slug}/version` or
// `https://api.modrinth.com/v2/version/{id}` request.
//
// ```json
// "dependencies": [
//     {
//         "version_id": null,
//         "project_id": "P7dR8mSH",
//         "file_name": null,
//         "dependency_type": "required"
//     }
// ]
// ```
//
// Don't confuse this Dependency with modrinth.index.json dependencies.

/// `RinthProject` pretends to be the response for:
/// `https://api.modrinth.com/v2/version/{version id}`
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
pub struct RinthVersion {
    pub name: String,
    pub version_number: String,
    pub game_versions: Vec<String>,
    pub version_type: String,
    pub loaders: Vec<String>,
    pub featured: bool,
    pub id: String,
    pub project_id: String,
    pub author_id: String,
    pub date_published: String,
    pub downloads: u64,
    pub files: Vec<RinthFile>,
    pub dependencies: Vec<Dependency>,
}

impl RinthVersion {
    pub fn get_file_url(&self) -> &str {
        &self.files[0].url
    }

    pub fn get_file_name(&self) -> &str {
        &self.files[0].filename
    }

    pub fn get_hashes(&self) -> &Hashes {
        &self.files[0].hashes
    }

    pub fn get_size(&self) -> usize {
        self.files[0].size
    }

    pub fn get_loader(&self) -> &str {
        &self.loaders[0]
    }

    pub fn is_fabric(&self) -> bool {
        self.loaders.iter().any(|l| l == "fabric")
    }

    pub fn has_dependencies(&self) -> bool {
        !self.dependencies.is_empty()
    }
}

/// RinthVersions pretends to parse the response of:
/// `https://api.modrinth.com/v2/project/{id | slug}/version`
/// This type is commonly use.
pub type RinthVersions = Vec<RinthVersion>;

/// Simple struct for representing the "hashes" object.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
pub struct Hashes {
    pub sha512: String,
    pub sha1: String,
}

/// This struct represents a file from [project/{id|slug}/version](https://api.modrinth.com/v2/project/BsfnmJP5/version)
/// request to the Modrinth's API.
///
///
/// This is part of a bigger json response:
/// ```json
/// "files": [
///   {
///     "hashes": {
///       "sha1": "fcd985acd9c44830dd542e4cf2b67b79745665c2",
///       "sha512": "hjdkashk139hdfksajsakjcxjsefwjo283..."
///     },
///     "url": "https://cdn.modrinth.com/data/BsfnmJP5/versions/u2NQZcGt/autocrafting-table-mod-1.0.8.jar",
///     "filename": "autocrafting-table-mod-1.0.8.jar",
///     "primary": true,
///     "size": 420424,
///     "file_type": null
///   }
/// ]
/// ```
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
pub struct RinthFile {
    pub hashes: Hashes,
    pub url: String,
    pub filename: String,
    pub primary: bool,
    pub size: usize,
}

/// This type correspond to [**category** query](https://api.modrinth.com/v2/tag/category)
/// to the Modrinth's API
pub type RinthCategories = Vec<Category>;

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug)]
pub struct Category {
    pub icon: String,
    pub name: String,
    pub project_type: String,
    pub header: String,
}

/// This struct represent the modrinth.index.json inside any
/// [Modrinth](https://modrinth.com) modpack.
///
/// ```json
///
/// {
///     "formatVersion": 1,
///     "game": "minecraft",
///     "versionId": "6.0.0-beta.5",
///     "name": "Fabulously Optimized",
///     "files": [
///         RinthMdFiles,
///         RinthMdFiles
///         ...
///     ],
///
///     "dependencies": {
///         RinthDep,
///         RinthDep,
///         ...
///     }
/// }
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
pub struct RinthModpack {
    #[cfg_attr(feature = "serde", serde(rename = "formatVersion"))]
    pub format_version: usize,
    pub game: String,
    #[cfg_attr(feature = "serde", serde(rename = "versionId"))]
    pub version_id: String,
    pub name: PathBuf,
    pub files: Vec<RinthMdFiles>,
}

impl RinthModpack {
    pub fn new() -> RinthModpack {
        RinthModpack::default()
    }

    pub fn new_with(version_id: String, name: PathBuf, files: Vec<RinthMdFiles>) -> Self {
        Self {
            format_version: 1,
            game: "minecraft".to_string(),
            version_id,
            name,
            files,
        }
    }

    pub fn get_mods(&self) -> &[RinthMdFiles] {
        &self.files
    }

    pub fn get_mut_mods(&mut self) -> &mut Vec<RinthMdFiles> {
        &mut self.files
    }

    pub fn get_name(&self) -> String {
        self.name.display().to_string()
    }

    pub fn get_files(&self) -> &Vec<RinthMdFiles> {
        &self.files
    }

    pub fn add_mod(&mut self, new_mod: RinthMdFiles) {
        self.files.push(new_mod);
    }

    #[cfg(feature = "serde")]
    pub fn write_mod_pack_with_name(&self) -> std::io::Result<()> {
        let j = serde_json::to_string_pretty(self)?;
        std::fs::write("modrinth.index.json", j)?;
        Ok(())
    }
}

impl std::default::Default for RinthModpack {
    fn default() -> Self {
        RinthModpack {
            format_version: 1,
            game: "minecraft".to_owned(),
            version_id: "0.0.0".to_owned(),
            name: "example".into(),
            files: Vec::new(),
        }
    }
}

/// This struct represent a mod inside the modrinth.index.json
/// file.
/// ```json
///
/// {
///     "path": "mods/Controlify-2.0.0-beta.14+1.21-fabric.jar",
///     "hashes": {
///          "sha1": "4643968fcdaee38ea921c0f4cc2cc1aebc21d058",
///          "sha512": "very_long_hash"
///      },
///     "env": {
///         "client": "required",
///         "server": "required"
///      },
///     "downloads": [
///         "download_link.com"
///     ],
///     "fileSize": 2791149
/// }
/// ```
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "camelCase"))]
#[derive(Debug, Clone)]
pub struct RinthMdFiles {
    pub path: PathBuf,
    pub hashes: Hashes,
    pub downloads: Vec<String>,
    pub file_size: usize,
}

impl From<RinthVersion> for RinthMdFiles {
    fn from(version: RinthVersion) -> RinthMdFiles {
        RinthMdFiles {
            path: ("mods/".to_owned() + version.get_file_name()).into(),
            hashes: version.get_hashes().clone(),
            downloads: vec![version.get_file_url().to_string()],
            file_size: version.get_size(),
        }
    }
}

impl From<RinthVersionFile> for RinthMdFiles {
    fn from(version: RinthVersionFile) -> Self {
        Self {
            path: ("mods/".to_owned() + &version.name).into(),
            hashes: version.files[0].hashes.clone(),
            downloads: vec![version.files[0].url.to_string()],
            file_size: version.files[0].size,
        }
    }
}

impl RinthMdFiles {
    pub fn get_download_link(&self) -> &str {
        &self.downloads[0]
    }

    pub fn get_id(&self) -> Option<&str> {
        /*
            So the download link should be something like this:
            https://cdn.modrinth.com/data/DOUdJVEm/versions/QiCZiPOr/Controlify-2.0.0-beta.14%2B1.21-fabric.jar
                                          ^^^^^^^^
            And this code just extract     this     part and return it.
        */

        for download_link in &self.downloads {
            if download_link.contains("modrinth") {
                return download_link.split("data/").nth(1).map(|f| &f[0..8]);
            }
        }
        None
    }

    pub fn get_name(&self) -> &str {
        // Oh god, I hate Rust strings.
        self.path.file_name().unwrap().to_str().unwrap_or_default()
    }

    pub fn get_path(&self) -> &Path {
        &self.path
    }

    pub fn get_sha1(&self) -> &str {
        &self.hashes.sha1
    }

    pub fn get_sha512(&self) -> &str {
        &self.hashes.sha512
    }
}

/// Represents a version file in the Modrinth API.
///
/// Corresponds to [**version_file** request](https://api.modrinth.com/v2/version_file/619e250c133106bacc3e3b560839bd4b324dfda8)
/// version_file/{hash}
///
///
/// This struct models the data for a specific version of a project, including
/// metadata such as the version number, supported Minecraft versions, and
/// download information.
///
/// # Note
///
/// The following fields are deprecated or not included in this struct:
///
/// - `changelog`: Describes changes in this version, either as a string or
///   null.
/// - `status`: The current status of the version (e.g., `"listed"`,
///   `"archived"`).
/// - `requested_status`: The requested status of the version.
/// - `changelog_url`: A deprecated link to the changelog, now always null.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone)]
pub struct RinthVersionFile {
    pub name: String,
    pub version_number: String,
    pub game_versions: Vec<String>,
    pub version_type: String,
    pub loaders: Vec<String>,
    pub featured: bool,
    pub id: String,
    pub project_id: String,
    pub author_id: String,
    pub date_published: String,
    pub downloads: u64,
    pub files: Vec<RinthFile>,

    #[cfg_attr(feature = "serde", serde(default = "Default::default"))]
    pub dependency: Vec<Dependency>,
}

#[cfg(feature = "serde")]
pub fn load_rinth_pack<I: AsRef<Path>>(pack_path: I) -> Option<RinthModpack> {
    read_to_string(&pack_path)
        .map(|s| serde_json::from_str(&s).ok())
        .ok()
        .flatten()
}