Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access values of NewType pattern response structs #24

Open
algoeng opened this issue Jan 24, 2021 · 3 comments
Open

How to access values of NewType pattern response structs #24

algoeng opened this issue Jan 24, 2021 · 3 comments

Comments

@algoeng
Copy link

algoeng commented Jan 24, 2021

The following response structs use the NewType pattern, and member .0 is private. There are no tests/examples on consuming the value of these. How do we access .0 member?

PostOrderCancelAllAfterResponse
GetSchemaResponse
GetSchemaWebsocketHelpResponse
GetUserExecutionHistoryResponse
GetUserMinWithdrawalFeeResponse

@dovahcrow
Copy link
Owner

Hi @Kr011 , thanks for the bug report. I'm working on a fix for this, however, it requires I modify the code generator since these definitions/models are directly generated from the swagger.json.

For now I think you can use std::mem::transmute to get the inner value. e.g.

let resp: PostOrderCancelAllAfterResponse = ...;
let inner: serde_json::Value = unsafe {std::mem::transmute(resp)};

@algoeng
Copy link
Author

algoeng commented Jan 24, 2021

Thank you for the quick response. That works for now. Feel free to close this, or keep it if you want to track fixing the code generator.

@dovahcrow
Copy link
Owner

I'll keep this until the issue is fixed.

Repository owner deleted a comment Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants