Skip to content

Commit

Permalink
fix: pub everything
Browse files Browse the repository at this point in the history
  • Loading branch information
sargon64 committed Aug 12, 2023
1 parent 5101de3 commit a324dcd
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 99 deletions.
4 changes: 2 additions & 2 deletions src/structs/forgemod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pub struct ForgeMod<Version: ManifestVersion, Comp: ManifestComponent, Inner: Fo
pub(crate) format_version: u32,
pub(crate) kind: String,

pub(crate) manifest: ForgeManifestSafe<Comp, Version>,
pub manifest: ForgeManifestSafe<Comp, Version>,

pub(crate) _inner: Inner,
pub data: Inner,

#[serde(skip)]
pub(crate) _marker: PhantomData<Version>,
Expand Down
8 changes: 4 additions & 4 deletions src/structs/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ pub struct ForgeManifest<Inner: ManifestComponent, Version: ManifestVersion> {
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub(crate) struct ForgeManifestSafe<Inner: ManifestComponent, Version: ManifestVersion> {
pub struct ForgeManifestSafe<Inner: ManifestComponent, Version: ManifestVersion> {
pub(crate) _id: String,
pub(crate) manifest_version: u32,
pub manifest_version: u32,
#[serde(rename = "type")]
pub(crate) _type: String,
pub _type: String,

// #[serde(flatten)] does not work with bincode
pub(crate) inner: Inner,
pub inner: Inner,

#[serde(skip)]
pub(crate) _marker: PhantomData<Version>,
Expand Down
156 changes: 63 additions & 93 deletions src/structs/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,91 +37,91 @@ mod manifest {

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
pub struct Dependency {
pub(super) name: String,
pub(super) version: VersionReq,
pub name: String,
pub version: VersionReq,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
pub struct Include {
pub(super) bs_dest: PathBuf,
pub(super) local_src: PathBuf,
pub bs_dest: PathBuf,
pub local_src: PathBuf,
}

/// type: mod
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Mod {
pub(super) name: String,
pub(super) description: String,
pub(super) website: String,
pub(super) version: Version,
pub(super) game_version: VersionReq,
pub(super) category: String,
pub name: String,
pub description: String,
pub website: String,
pub version: Version,
pub game_version: VersionReq,
pub category: String,

pub(super) artifact: Option<PathBuf>, // not actually optional
pub(super) includes: Vec<Include>,
pub artifact: Option<PathBuf>, // not actually optional
pub includes: Vec<Include>,

pub(super) pre_exec: Option<PathBuf>,
pub(super) post_exec: Option<PathBuf>,
pub pre_exec: Option<PathBuf>,
pub post_exec: Option<PathBuf>,

pub(super) depends: Vec<Dependency>,
pub(super) conflicts: Vec<Dependency>,
pub depends: Vec<Dependency>,
pub conflicts: Vec<Dependency>,
}

/// type: module_parent
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Parent {
pub(super) name: String,
pub(super) description: String,
pub(super) website: String,
pub(super) version: Version,
pub(super) game_version: VersionReq,
pub(super) category: String,
pub name: String,
pub description: String,
pub website: String,
pub version: Version,
pub game_version: VersionReq,
pub category: String,

pub(super) pre_exec: Option<PathBuf>,
pub(super) post_exec: Option<PathBuf>,
pub pre_exec: Option<PathBuf>,
pub post_exec: Option<PathBuf>,

pub(super) depends: Vec<Dependency>,
pub(super) conflicts: Vec<Dependency>,
pub depends: Vec<Dependency>,
pub conflicts: Vec<Dependency>,

pub(super) modules: Vec<PathBuf>,
pub modules: Vec<PathBuf>,
}

/// type: module
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
pub struct Module {
pub(super) name: String,
pub name: String,

pub(super) required: bool,
pub(super) suggested: bool,
pub required: bool,
pub suggested: bool,

pub(super) artifact: Option<PathBuf>, // not actually optional
pub(super) includes: Vec<Include>,
pub artifact: Option<PathBuf>, // not actually optional
pub includes: Vec<Include>,

pub(super) pre_exec: Option<PathBuf>,
pub(super) post_exec: Option<PathBuf>,
pub pre_exec: Option<PathBuf>,
pub post_exec: Option<PathBuf>,

pub(super) depends: Vec<Dependency>,
pub(super) conflicts: Vec<Dependency>,
pub depends: Vec<Dependency>,
pub conflicts: Vec<Dependency>,
}

/// type: lib
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Lib {
pub(super) name: String,
pub(super) description: String,
pub(super) website: String,
pub(super) version: Version,
pub(super) game_version: VersionReq,
pub(super) category: String,
pub name: String,
pub description: String,
pub website: String,
pub version: Version,
pub game_version: VersionReq,
pub category: String,

pub(super) artifact: Option<PathBuf>, // not actually optional
pub(super) includes: Vec<Include>,
pub artifact: Option<PathBuf>, // not actually optional
pub includes: Vec<Include>,

pub(super) pre_exec: Option<PathBuf>,
pub(super) post_exec: Option<PathBuf>,
pub pre_exec: Option<PathBuf>,
pub post_exec: Option<PathBuf>,

pub(super) depends: Vec<Dependency>,
pub(super) conflicts: Vec<Dependency>,
pub depends: Vec<Dependency>,
pub conflicts: Vec<Dependency>,
}

impl ManifestComponent for Mod {}
Expand Down Expand Up @@ -407,36 +407,36 @@ mod data {

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct IncludeData {
pub(super) dest: String,
pub dest: String,
#[serde(with = "serde_bytes")]
pub(super) data: Vec<u8>,
pub data: Vec<u8>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Mod {
#[serde(with = "serde_bytes")]
pub(super) artifact_data: Vec<u8>,
pub(super) includes_data: Vec<IncludeData>,
pub artifact_data: Vec<u8>,
pub includes_data: Vec<IncludeData>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Parent {}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Module {
pub(super) _id: String,
pub(super) required: bool,
pub(super) suggested: bool,
pub _id: String,
pub required: bool,
pub suggested: bool,
#[serde(with = "serde_bytes")]
pub(super) artifact_data: Vec<u8>,
pub(super) includes_data: Vec<IncludeData>,
pub artifact_data: Vec<u8>,
pub includes_data: Vec<IncludeData>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Lib {
#[serde(with = "serde_bytes")]
pub(super) artifact_data: Vec<u8>,
pub(super) includes_data: Vec<IncludeData>,
pub artifact_data: Vec<u8>,
pub includes_data: Vec<IncludeData>,
}

impl ForgeModData for Mod {}
Expand Down Expand Up @@ -488,22 +488,12 @@ impl ModBuilder<manifest::Mod, data::Mod> {
format_version: 1,
kind: "mod".into(),
manifest: self._manifest.into(),
_inner: self._inner,
data: self._inner,
_marker: PhantomData,
}
}
}

impl ForgeMod<ManifestV1, manifest::Mod, data::Mod> {
pub fn artifact_data(&self) -> &[u8] {
&self._inner.artifact_data
}

pub fn includes_data(&self) -> &[data::IncludeData] {
&self._inner.includes_data
}
}

impl ModBuilder<manifest::Parent, data::Parent> {
pub fn new_module_parent(manifest: ForgeManifest<manifest::Parent, ManifestV1>) -> Self {
Self {
Expand All @@ -517,7 +507,7 @@ impl ModBuilder<manifest::Parent, data::Parent> {
format_version: 1,
kind: "parent".into(),
manifest: self._manifest.into(),
_inner: self._inner,
data: self._inner,
_marker: PhantomData,
}
}
Expand Down Expand Up @@ -566,22 +556,12 @@ impl ModBuilder<manifest::Module, data::Module> {
format_version: 1,
kind: "module".into(),
manifest: self._manifest.into(),
_inner: self._inner,
data: self._inner,
_marker: PhantomData,
}
}
}

impl ForgeMod<ManifestV1, manifest::Module, data::Module> {
pub fn artifact_data(&self) -> &[u8] {
&self._inner.artifact_data
}

pub fn includes_data(&self) -> &[data::IncludeData] {
&self._inner.includes_data
}
}

impl ModBuilder<manifest::Lib, data::Lib> {
pub fn new_lib_raw(manifest: ForgeManifest<manifest::Lib, ManifestV1>, artifact_data: Vec<u8>) -> Self {
Self {
Expand Down Expand Up @@ -616,22 +596,12 @@ impl ModBuilder<manifest::Lib, data::Lib> {
format_version: 1,
kind: "lib".into(),
manifest: self._manifest.into(),
_inner: self._inner,
data: self._inner,
_marker: PhantomData,
}
}
}

impl ForgeMod<ManifestV1, manifest::Lib, data::Lib> {
pub fn artifact_data(&self) -> &[u8] {
&self._inner.artifact_data
}

pub fn includes_data(&self) -> &[data::IncludeData] {
&self._inner.includes_data
}
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct IncludeDataBuilder {
pub(self) _inners: Vec<data::IncludeData>,
Expand Down

0 comments on commit a324dcd

Please sign in to comment.