From 170a459a3dcb206393d0df235114d209f653ee62 Mon Sep 17 00:00:00 2001 From: Lachezar Lechev Date: Sat, 21 Jan 2023 12:13:25 +0200 Subject: [PATCH] chore(docs): ManifestBehaviorHints test fixes and example Signed-off-by: Lachezar Lechev --- src/types/addon/manifest.rs | 29 ++++++++++++++++++- .../serde/manifest_behavior_hints.rs | 4 +++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/types/addon/manifest.rs b/src/types/addon/manifest.rs index dc9d89c11..5114c2791 100644 --- a/src/types/addon/manifest.rs +++ b/src/types/addon/manifest.rs @@ -274,6 +274,33 @@ impl Default for OptionsLimit { } } +/// +/// # Examples +/// +/// ``` +/// use stremio_core::types::addon::ManifestBehaviorHints; +/// +/// use serde_json::{from_value, json}; +/// +/// let json = json!({ +/// "adult": true, +/// "p2p": true, +/// "configurable": true, +/// "configuration_required": true, +/// "new_episode_notifications": true, +/// "unknown_property": "unknown property data", +/// }); +/// +/// let actual = from_value::(json).expect("Should deserialize"); +/// +/// let expected = ManifestBehaviorHints { +/// adult: true, +/// p2p: true, +/// configurable: true, +/// configuration_required: true, +/// new_episode_notifications: true, +/// }; +/// ``` #[derive(Default, Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] pub struct ManifestBehaviorHints { @@ -288,5 +315,5 @@ pub struct ManifestBehaviorHints { /// Whether or not the add-on supports notifications for new episodes. // TODO: Define the new catalog for Add-ons #[serde(default)] - pub new_episodes_notifications: bool, + pub new_episode_notifications: bool, } diff --git a/src/unit_tests/serde/manifest_behavior_hints.rs b/src/unit_tests/serde/manifest_behavior_hints.rs index 524c32809..14175e0b5 100644 --- a/src/unit_tests/serde/manifest_behavior_hints.rs +++ b/src/unit_tests/serde/manifest_behavior_hints.rs @@ -9,6 +9,7 @@ fn manifest_behavior_hints() { p2p: true, configurable: true, configuration_required: true, + new_episode_notifications: true, }, &[ Token::Struct { @@ -23,6 +24,8 @@ fn manifest_behavior_hints() { Token::Bool(true), Token::Str("configurationRequired"), Token::Bool(true), + Token::Str("newEpisodeNotifications"), + Token::Bool(true), Token::StructEnd, ], ); @@ -32,6 +35,7 @@ fn manifest_behavior_hints() { p2p: false, configurable: false, configuration_required: false, + new_episode_notifications: false, }, &[ Token::Struct {