Skip to content
This repository has been archived by the owner on Nov 14, 2022. It is now read-only.

margin_fraction and open_margin_fraction can be null #44

Merged
merged 1 commit into from
Sep 3, 2021

Conversation

dovahcrow
Copy link
Collaborator

No description provided.

@dovahcrow
Copy link
Collaborator Author

dovahcrow commented Sep 3, 2021

Also suggest do not use the enum here: https://github.com/fabianboesiger/ftx/blob/main/src/rest/model.rs#L12.

Crypto exchange protocols change rapidly. Using enum will only produce an unhelpful data did not match any variant of untagged enum Response error.

A better solution would be to deserialize the payload into a string first.
After that, try to deserialize the string into Result { success: bool, result: T }, if succeeded, return it to the user. If not, write down the error into a variable.
Then, deserialize the string into Error { success: bool, error: String }, if succeeded, return it to the user. If not, return the error written down in the first step.

The overhead to string is fine because when using enum, serde will buffer the content as well. https://github.com/serde-rs/serde/blob/master/serde/src/private/de.rs#L219

@fabianboesiger fabianboesiger merged commit 42a7f41 into fabianboesiger:main Sep 3, 2021
@fabianboesiger
Copy link
Owner

The changed payload deserialisation seems like a good idea, I ran into that error a few times as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants