Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more unknown variants #105

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/modules/civilization/models/crime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ pub enum Crime {

#[serde(rename = "onFoot_propertyTheft")]
OnFootPropertyTheft,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
#[serde(untagged)]
Unknown(String),
}

#[cfg(test)]
Expand Down
17 changes: 17 additions & 0 deletions src/modules/civilization/models/engineer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ pub enum Engineer {
/// This is a special engineer that does not actually exist, but seems to be used for
/// pre-engineered modules.
System,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
#[serde(untagged)]
Unknown(String),
}

impl Engineer {
Expand Down Expand Up @@ -92,6 +97,9 @@ impl Engineer {
Engineer::RosaDayette => 400012,
Engineer::YiShen => 400013,
Engineer::System => 399999,

#[cfg(feature = "allow-unknown")]
Engineer::Unknown(_) => 0,
}
}

Expand Down Expand Up @@ -136,6 +144,9 @@ impl Engineer {
Engineer::RosaDayette => 59166629864010,
Engineer::YiShen => 13736779007129,
Engineer::System => 0,

#[cfg(feature = "allow-unknown")]
Engineer::Unknown(_) => 0,
}
}

Expand Down Expand Up @@ -180,6 +191,9 @@ impl Engineer {
Engineer::RosaDayette => 128986587,
Engineer::YiShen => 128987355,
Engineer::System => 0,

#[cfg(feature = "allow-unknown")]
Engineer::Unknown(_) => 0,
}
}
}
Expand Down Expand Up @@ -229,6 +243,9 @@ impl Display for Engineer {
Engineer::RosaDayette => "Rosa Dayette",
Engineer::YiShen => "Yi Shen",
Engineer::System => "System",

#[cfg(feature = "allow-unknown")]
Engineer::Unknown(unknown) => return write!(f, "Unknown engineer: {}", unknown),
}
)
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/exploration/models/codex_anomaly_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use thiserror::Error;

/// Codex entries related to anomalies.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum CodexAnomalyEntry {
LagrangeClouds,

Expand Down
1 change: 1 addition & 0 deletions src/modules/exploration/models/codex_geological_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use thiserror::Error;

/// Codex entries related to geological points-of-interest.
#[derive(Debug, Serialize, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum CodexGeologicalEntry {
Fumarole,
FumaroleAmmoniaGeysers,
Expand Down
1 change: 1 addition & 0 deletions src/modules/exploration/models/codex_guardian_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::str::FromStr;
use thiserror::Error;

#[derive(Debug, Serialize, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum CodexGuardianEntry {
AncientCasket,
AncientKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use thiserror::Error;
/// Codex entries related to organic structures other than the ones already covered by
/// [crate::exobiology::Genus], [crate::exobiology::Species] and [crate::exobiology::Variant].
#[derive(Debug, Serialize, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum CodexOrganicStructureEntry {
StolonTree,

Expand Down
1 change: 1 addition & 0 deletions src/modules/exploration/models/codex_thargoid_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use thiserror::Error;

/// Codex entries related to Thargoids.
#[derive(Debug, Serialize, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum CodexThargoidEntry {
LargeSpike,
Tower,
Expand Down
5 changes: 5 additions & 0 deletions src/modules/galaxy/models/atmosphere_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ pub enum AtmosphereType {

#[serde(alias = "metallic vapour")]
MetallicVapour,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
#[serde(untagged)]
Unknown(String),
}

impl FromStr for AtmosphereType {
Expand Down
4 changes: 0 additions & 4 deletions src/modules/galaxy/models/body_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@ pub enum BodyType {

// TODO add description on when this is used
Null,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
Unknown(String),
}
2 changes: 1 addition & 1 deletion src/modules/galaxy/models/star_luminosity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@
assert!(StarLuminosity::Vb > StarLuminosity::Vz);
assert!(StarLuminosity::Vz > StarLuminosity::VI);
assert!(StarLuminosity::VI > StarLuminosity::VII);
assert!(StarLuminosity::VII > StarLuminosity::Zero);

Check warning on line 102 in src/modules/galaxy/models/star_luminosity.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/ed-journals/ed-journals/src/modules/galaxy/models/star_luminosity.rs
}
}
}
8 changes: 8 additions & 0 deletions src/modules/odyssey/models/citizen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ pub enum Citizen {
alias = "rangedsuitai_class3"
)]
Sniper,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
#[serde(untagged)]
Unknown(String),
}

impl Display for Citizen {
Expand All @@ -62,6 +67,9 @@ impl Display for Citizen {
Citizen::Scout => "Scout",
Citizen::Striker => "Striker",
Citizen::Sniper => "Sniper",

#[cfg(feature = "allow-unknown")]
Citizen::Unknown(unknown) => return write!(f, "Unknown citizen: {}", unknown),
}
)
}
Expand Down
6 changes: 6 additions & 0 deletions src/modules/odyssey/models/suit_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize};
/// A mod applied to a suit.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum SuitMod {
/// Reduces the battery consumption of the suit's utility tool.
#[serde(rename = "suit_reducedtoolbatteryconsumption")]
Expand Down Expand Up @@ -59,4 +60,9 @@ pub enum SuitMod {
/// Decreases noise and in turn improves stealth.
#[serde(rename = "suit_quieterfootsteps")]
QuieterFootsteps,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
#[serde(untagged)]
Unknown(String),
}
9 changes: 9 additions & 0 deletions src/modules/odyssey/models/weapon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::fmt::{Display, Formatter};
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum Weapon {
#[serde(
alias = "Wpn_M_AssaultRifle_Kinetic_FAuto",
Expand Down Expand Up @@ -66,6 +67,11 @@ pub enum Weapon {

#[serde(alias = "Wpn_S_Pistol_Laser_SAuto", alias = "wpn_s_pistol_laser_sauto")]
TKZenith,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
#[serde(untagged)]
Unknown(String),
}

impl Display for Weapon {
Expand All @@ -87,6 +93,9 @@ impl Display for Weapon {
Weapon::TKAphelion => "TK Aphelion",
Weapon::TKEclipse => "TK Eclipse",
Weapon::TKZenith => "TK Zenith ",

#[cfg(feature = "allow-unknown")]
Weapon::Unknown(unknown) => return write!(f, "Unknown weapon {}", unknown),
}
)
}
Expand Down
6 changes: 6 additions & 0 deletions src/modules/odyssey/models/weapon_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize};
/// A mod applied to an Odyssey weapon.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum WeaponMod {
#[serde(rename = "weapon_handling")]
FasterHandling,
Expand Down Expand Up @@ -33,4 +34,9 @@ pub enum WeaponMod {

#[serde(rename = "weapon_stability")]
Stability,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
#[serde(untagged)]
Unknown(String),
}
1 change: 1 addition & 0 deletions src/modules/ship/models/blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::fmt::{Display, Formatter};

/// Engineering blueprint that can be applied to certain ship modules.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum Blueprint {
// Armor
#[serde(rename = "Armour_Explosive")]
Expand Down
1 change: 1 addition & 0 deletions src/modules/ship/models/blueprint_modifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize};
/// When applying blueprint to modules, modifiers are applied to the modules which are the things
/// that actually change the stats of the module.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum BlueprintModifier {
Size,
Class,
Expand Down
6 changes: 6 additions & 0 deletions src/modules/ship/models/fighter_loadout.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum FighterLoadout {
#[serde(rename = "zero")]
Zero,
Expand All @@ -22,4 +23,9 @@ pub enum FighterLoadout {

#[serde(rename = "starter")]
Starter,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
#[serde(untagged)]
Unknown(String),
}
6 changes: 6 additions & 0 deletions src/modules/ship/models/fighter_type.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum FighterType {
#[serde(rename = "independent_fighter")]
Taipan,
Expand All @@ -10,4 +11,9 @@ pub enum FighterType {

#[serde(rename = "federation_fighter")]
F63Condor,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
#[serde(untagged)]
Unknown(String),
}
1 change: 1 addition & 0 deletions src/modules/ship/models/ship_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub mod ship_weapon_color;
///
/// The same is true for core internals and optional internals which both use [ShipInternalModule].
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum ShipModule {
/// Special case for the cargo bay door.
#[serde(
Expand Down
4 changes: 4 additions & 0 deletions src/modules/ship/models/ship_slot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

// TODO kinda want to refactor this to use untagged variants
#[derive(Debug, Serialize, Clone, PartialEq)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum ShipSlotKind {
ShipCockpit,
CargoHatch,
Expand All @@ -44,9 +45,12 @@
EngineColor,
WeaponColor,
ShipKitSpoiler,
ShipKitWings,

Check warning on line 48 in src/modules/ship/models/ship_slot.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/ed-journals/ed-journals/src/modules/ship/models/ship_slot.rs
ShipKitTail,
ShipKitBumper,

// There is currently no Unknown variant here as it wouldn't make sense to have an unknown kind
// and then return a ShipSlot after parsing.
}

#[derive(Debug, Error)]
Expand Down
9 changes: 9 additions & 0 deletions src/modules/ship/models/srv_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ use std::fmt::{Display, Formatter};
use serde::{Deserialize, Serialize};

#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum SRVType {
#[default]
#[serde(rename = "testbuggy")]
Scarab,

#[serde(rename = "combat_multicrew_srv_01")]
Scorpion,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
#[serde(untagged)]
Unknown(String),
}

impl Display for SRVType {
Expand All @@ -20,6 +26,9 @@ impl Display for SRVType {
match self {
SRVType::Scarab => "Scarab",
SRVType::Scorpion => "Scorpion",

#[cfg(feature = "allow-unknown")]
SRVType::Unknown(unknown) => return write!(f, "Unknown SRV type: {}", unknown),
}
)
}
Expand Down
2 changes: 2 additions & 0 deletions src/modules/status/models/gui_focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl TryFrom<u8> for GuiFocus {
9 => GuiFocus::FSSMode,
10 => GuiFocus::SAAMode,
11 => GuiFocus::Codex,

_ => return Err(GuiFocusError::UnknownValue(value)),
})
}
Expand All @@ -68,6 +69,7 @@ impl FromStr for GuiFocus {
"FSSMode" => GuiFocus::FSSMode,
"SAAMode" => GuiFocus::SAAMode,
"Codex" => GuiFocus::Codex,

_ => return Err(GuiFocusError::UnknownStringValue(s.to_string())),
})
}
Expand Down
6 changes: 6 additions & 0 deletions src/modules/thargoid/models/thargoid_ship.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[cfg_attr(not(feature = "allow-unknown"), non_exhaustive)]
pub enum ThargoidShip {
#[serde(rename = "scout_hq")]
Scout,

#[serde(rename = "glaive")]
Glaive,

#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
#[serde(untagged)]
Unknown(String),
}
Loading