wisespace-io / binance-rs

Rust Library for the Binance API
Other
665 stars 297 forks source link

Changing websocket callback to return a Result to allow smarter error… #29

Closed LucasSimpson closed 5 years ago

LucasSimpson commented 5 years ago

If there's a better/established way of doing this, let me know.

Currently the WebSockets callback doesn't have any return value. The event_loop() returns a Result, but it's limited to errors that might arise strictly from the websockets. Any problems within the callback is limited to a panic. Allowing the callback to return its own Result, that would be bubbled up through to the return value of the event_loop() helps write smarter error handling around websocket events.

This changes the function signature of the callback arg, thus breaking the current API. I've gone and updated the examples, but consumers will not be able to simply upgrade the package version without modifications themselves