Skip to content

Commit

Permalink
chore(docs): ManifestBehaviorHints test fixes and example
Browse files Browse the repository at this point in the history
Signed-off-by: Lachezar Lechev <[email protected]>
  • Loading branch information
elpiel committed Jan 21, 2023
1 parent ce7a6c8 commit 170a459
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/types/addon/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<ManifestBehaviorHints>(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 {
Expand All @@ -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,
}
4 changes: 4 additions & 0 deletions src/unit_tests/serde/manifest_behavior_hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fn manifest_behavior_hints() {
p2p: true,
configurable: true,
configuration_required: true,
new_episode_notifications: true,
},
&[
Token::Struct {
Expand All @@ -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,
],
);
Expand All @@ -32,6 +35,7 @@ fn manifest_behavior_hints() {
p2p: false,
configurable: false,
configuration_required: false,
new_episode_notifications: false,
},
&[
Token::Struct {
Expand Down

0 comments on commit 170a459

Please sign in to comment.