hgame 0.26.4

CG production management structs, e.g. of assets, personnels, progress, etc.
Documentation
use super::*;
use crate::link::ExternalLink;

#[derive(Debug, Serialize, Deserialize)]
/// Represents the "singleton" document in the `ProjectMetadata` collection of a project.
pub struct ProjLink {
    #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
    id: Option<ObjectId>,

    /// LEGACY DESIGN: used to "ensure" querying into this collection always return the same document.
    /// Must be `true` in order for the doc to be found.
    singleton: bool,

    /// Contains all external URLs defined by elevated users, e.g. Producers.
    /// `web_page` field is legacy, and `web_page_v2` plans to support more flexible
    /// user customization. It must be behind an `Option` to avoid deser fails with existing
    /// legacy collections.
    #[serde(rename = "web_page_v2")]
    /// This field won't cause deser fail, as it's "normal" `serde`.
    pub web_page: Option<Vec<ExternalLink>>,
}

impl Default for ProjLink {
    fn default() -> Self {
        Self {
            id: None,
            singleton: true,
            web_page: Some(vec![]),
        }
    }
}

impl BsonId for ProjLink {
    fn bson_id_as_ref(&self) -> Option<&ObjectId> {
        self.id.as_ref()
    }

    fn bson_id(&self) -> AnyResult<&ObjectId> {
        self.id.as_ref().context("ProjLink without BSON ObjectId")
    }
}