-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using serde annotations instead of wrapper types
- Loading branch information
Showing
11 changed files
with
82 additions
and
40 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
14 changes: 8 additions & 6 deletions
14
implementations/plugin-rust/src/helpers/serde_annotate_if_bytes.rs
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,14 +1,16 @@ | ||
use handlebars::handlebars_helper; | ||
use serde_json::{Value}; | ||
use serde_json::Value; | ||
|
||
handlebars_helper!(serde_annotate_if_bytes: |val: Value| { | ||
let name = val.as_str().unwrap(); | ||
_serde_annotate_if_bytes(name) | ||
_serde_annotate_if_wrapper(name) | ||
}); | ||
|
||
pub fn _serde_annotate_if_bytes(val: &str) -> String { | ||
if val == "Bytes" { | ||
return "#[serde(with = \"bytes\")]\n ".to_string(); | ||
pub fn _serde_annotate_if_wrapper(val: &str) -> String { | ||
match val { | ||
"Bytes" => "#[serde(with = \"bytes\")]\n ".to_string(), | ||
"JSON" => "#[serde(with = \"json\")]\n ".to_string(), | ||
"BigInt" => "#[serde(with = \"bigint\")]\n ".to_string(), | ||
_ => "".to_string(), | ||
} | ||
"".to_string() | ||
} |
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