bitmex-rs
bitmex-rs copied to clipboard
How to access values of NewType pattern response structs
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
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)};
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.
I'll keep this until the issue is fixed.