coinnect icon indicating copy to clipboard operation
coinnect copied to clipboard

Return type of return_order_book should not be a Map

Open dovahcrow opened this issue 7 years ago • 4 comments

Actually, not all return value from Poloniex is a JSON object, for now, return_order_book is an exception. I make a change to these methods to return Result<T>, which delegates the choice to the user that he can decide what type the result value is. Commit.

dovahcrow avatar Jan 21 '18 07:01 dovahcrow

Using the Deserialize from Serde seems a great idea. However does it break the generic API ? I didn't run tests to check it.

hugues31 avatar Mar 24 '18 09:03 hugues31

I don't think so. Since the generic API assumes the return type as a Map, so the compiler will infer T as a Map. Then everything falls back to the original Map API.

dovahcrow avatar Mar 25 '18 07:03 dovahcrow

Actually using generic is just a workaround. Finally, I think we need to type-ify all the return types. Something like this is pretty useful.

dovahcrow avatar Mar 25 '18 07:03 dovahcrow

Yes but I think that a strong typed return should be the purpose of the generic API, the raw API, which is lower level, should stay close to the exchange response. Eventually, the Map container may be changed.

hugues31 avatar Mar 26 '18 16:03 hugues31