Skip to content

Commit

Permalink
📝 Add doc comments to new codex models
Browse files Browse the repository at this point in the history
  • Loading branch information
rster2002 committed Sep 28, 2024
1 parent 45bfc84 commit abe20bf
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/modules/exobiology/models/genus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub enum Genus {
}

impl Genus {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
Expand Down
1 change: 1 addition & 0 deletions src/modules/exobiology/models/species.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ lazy_static! {
}

impl Species {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
Expand Down
1 change: 1 addition & 0 deletions src/modules/exobiology/models/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct Variant {
}

impl Variant {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
Expand Down
8 changes: 2 additions & 6 deletions src/modules/exploration/models/codex_anomaly_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::fmt::{Display, Formatter};
use std::str::FromStr;
use thiserror::Error;

/// Codex entries related to anomalies.
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
pub enum CodexAnomalyEntry {
LagrangeClouds,
Expand Down Expand Up @@ -43,18 +44,13 @@ pub enum CodexAnomalyEntry {

SilicateStructures,

// ETypeAnomalies,
// KTypeAnomalies,
// LTypeAnomalies,
// PTypeAnomalies,
// QTypeAnomalies,
// TTypeAnomalies,
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
Unknown(String),
}

impl CodexAnomalyEntry {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
Expand Down
11 changes: 10 additions & 1 deletion src/modules/exploration/models/codex_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::fmt::{Display, Formatter};
use std::str::FromStr;
use thiserror::Error;

/// Codex entry name.
/// Model for any kind of codex entry.
#[derive(Debug, Serialize, Clone, PartialEq, Eq, Hash)]
pub enum CodexEntry {
Planet(CodexPlanetEntry),
Expand All @@ -32,6 +32,15 @@ pub enum CodexEntry {
Unknown(String),
}

impl CodexEntry {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
matches!(self, CodexEntry::Unknown(_))
}
}

#[derive(Debug, Error)]
pub enum CodexEntryError {
#[error("Unknown codex entry: '{0}'")]
Expand Down
8 changes: 2 additions & 6 deletions src/modules/exploration/models/codex_geological_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::fmt::{Display, Formatter};
use std::str::FromStr;
use thiserror::Error;

/// Codex entries related to geological points-of-interest.
#[derive(Debug, Serialize, Clone, PartialEq, Eq, Hash)]
pub enum CodexGeologicalEntry {
Fumarole,
Expand Down Expand Up @@ -66,6 +67,7 @@ pub enum CodexGeologicalEntry {
}

impl CodexGeologicalEntry {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
Expand Down Expand Up @@ -177,12 +179,6 @@ impl Display for CodexGeologicalEntry {
f,
"{}",
match self {
// CodexGeologicalEntry::Fumarole => "Fumarole",
// CodexGeologicalEntry::IceFumarole => "Ice Fumarole",
// CodexGeologicalEntry::Geyser => "Geyser",
// CodexGeologicalEntry::IceGeyser => "Ice Geyser",
// CodexGeologicalEntry::LavaSpout => "Lava Spout",
// CodexGeologicalEntry::GasVent => "Gas Vent",
CodexGeologicalEntry::Fumarole => "Fumarole",
CodexGeologicalEntry::FumaroleAmmoniaGeysers => "Ammonia Fumarole",
CodexGeologicalEntry::FumaroleCarbondioxideGeysers => "Carbon Dioxide Fumarole",
Expand Down
2 changes: 2 additions & 0 deletions src/modules/exploration/models/codex_guardian_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ pub enum CodexGuardianEntry {
}

impl CodexGuardianEntry {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
matches!(self, CodexGuardianEntry::Unknown(_))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::fmt::{Display, Formatter};
use std::str::FromStr;
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)]
pub enum CodexOrganicStructureEntry {
StolonTree,
Expand All @@ -14,6 +16,7 @@ pub enum CodexOrganicStructureEntry {
}

impl CodexOrganicStructureEntry {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
Expand Down
2 changes: 2 additions & 0 deletions src/modules/exploration/models/codex_planet_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::fmt::{Display, Formatter};
use std::str::FromStr;
use thiserror::Error;

/// Codex entries related to planet types.
#[derive(Debug, Serialize, Clone, PartialEq, Eq, Hash)]
pub enum CodexPlanetEntry {
EarthLike,
Expand Down Expand Up @@ -135,6 +136,7 @@ pub enum CodexPlanetEntry {
}

impl CodexPlanetEntry {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
Expand Down
3 changes: 2 additions & 1 deletion src/modules/exploration/models/codex_star_class_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::from_str_deserialize_impl;
use serde::Serialize;
use thiserror::Error;

/// New-type used for parsing star class codex entries.
/// Codex entries related to star class.
#[derive(Debug, Serialize, Clone, PartialEq, Eq, Hash)]
pub enum CodexStarClassEntry {
ATypes,
Expand Down Expand Up @@ -167,6 +167,7 @@ pub enum CodexStarClassEntry {
}

impl CodexStarClassEntry {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
Expand Down
2 changes: 2 additions & 0 deletions src/modules/exploration/models/codex_thargoid_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::fmt::Display;
use std::str::FromStr;
use thiserror::Error;

/// Codex entries related to Thargoids.
#[derive(Debug, Serialize, Clone, PartialEq, Eq, Hash)]
pub enum CodexThargoidEntry {
LargeSpike,
Expand Down Expand Up @@ -57,6 +58,7 @@ pub enum CodexThargoidEntry {
}

impl CodexThargoidEntry {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
Expand Down
9 changes: 9 additions & 0 deletions src/modules/exploration/models/planetary_signal_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ pub enum PlanetarySignalType {
Unknown(String),
}

impl PlanetarySignalType {
/// Whether the current variant is unknown.
#[cfg(feature = "allow-unknown")]
#[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
pub fn is_unknown(&self) -> bool {
matches!(self, PlanetarySignalType::Unknown(_))
}
}

impl Display for PlanetarySignalType {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
Expand Down

0 comments on commit abe20bf

Please sign in to comment.