openconfiguration/
catalog_entry.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5use crate::impl_visitable_noop;
6
7#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
9#[cfg_attr(feature = "schema", schemars(deny_unknown_fields))]
10#[serde(rename_all = "camelCase")]
11pub struct CatalogEntry {
12    pub entry_type: CatalogEntryType,
13    /// Id of the entry. Needed if catalog processing is done server side.
14    pub entry_id: String,
15    /// Localized entry text. Key is ISO 639-1 language code.
16    #[serde(deserialize_with = "crate::utils::deserialize_map_without_null_values")]
17    pub entry_text: HashMap<String, Vec<String>>,
18    /// For type Article, the native id of the article to be created.
19    pub article_id: String,
20    /// For type Folder, the contained entries: folders and/or articles
21    pub entries: Vec<CatalogEntry>,
22}
23
24impl_visitable_noop!(CatalogEntry);
25
26#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
27#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
28pub enum CatalogEntryType {
29    Folder,
30    Article,
31}