-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
281 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod mapping; | ||
pub mod network; | ||
pub mod profile; | ||
mod serializer; | ||
pub mod sports; | ||
pub mod stream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use serde_json::{Map, Value}; | ||
|
||
use super::{mapping::MapError, profile::ProfileCompositionMapping}; | ||
|
||
// Same as in assets/root_composition_script.js | ||
const APPLY_CHECKBOX_KEY: &str = "__APPLY_CHECKBOX"; | ||
|
||
pub fn serialize_mappings( | ||
mappings: &Vec<ProfileCompositionMapping>, | ||
source: &Value, | ||
exclude_incomplete_data: bool, | ||
) -> Result<Value, MapError> { | ||
let mut map = Map::with_capacity(mappings.len()); | ||
for comp_mapping in mappings { | ||
let mut mapped_obj = comp_mapping.mapping.map(&source, exclude_incomplete_data)?; | ||
if let Some(ref key) = comp_mapping.enabled_checkbox_name { | ||
mapped_obj | ||
.as_object_mut() | ||
.unwrap() | ||
.insert(APPLY_CHECKBOX_KEY.to_owned(), Value::String(key.clone())); | ||
} | ||
map.insert(comp_mapping.subcomp_name.clone(), mapped_obj); | ||
} | ||
Ok(Value::Object(map)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.