This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Sier codec wasm binding. #140
Open
melatron
wants to merge
8
commits into
master
Choose a base branch
from
melatron/sier-wasm-binding
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
9dc607b
to
0c70ce1
Compare
0dafc81
to
d731d3d
Compare
shelbyd
suggested changes
Apr 19, 2022
shelbyd
approved these changes
May 4, 2022
support/sier-codec-js/src/lib.rs
Outdated
|
||
let mut parser = Parser::default(); | ||
parser.add_file_defs(file_defs).unwrap_or_else(|e| { | ||
wasm_bindgen::throw_str(e.to_string().as_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of throw_str(s.as_str())
you should be able to throw_str(&s)
. Same elsewhere.
#[wasm_bindgen] | ||
pub fn serialize(js_object: JsValue, file_defs: &str, struct_def: &str) -> js_sys::Uint8Array { | ||
if !js_object.is_object() { | ||
wasm_bindgen::throw_str("Provided argument is not a JS Object."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might be able to have these functions return Result<T, JsValue>
instead of explicitly throwing everywhere. More idiomatic and probably easier to read/write. Might even be able to use the ?
operator.
shelbyd
suggested changes
May 18, 2022
Comment on lines
+11
to
+13
let json = js_sys::JSON::stringify(&js_object).unwrap_or_else(|e| { | ||
wasm_bindgen::throw_val(e); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be doable as:
let json = js_sys::JSON::stringify(&js_object)?;
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.