pleshevskiy / sonic-channel

Rust client for sonic search backend
Mozilla Public License 2.0
41 stars 8 forks source link

Separate structs for each channel mode #3

Closed tvolk131 closed 3 years ago

tvolk131 commented 3 years ago

It's a bit unintuitive to set the channel mode when creating an instance of the SonicChannel client while still allowing potentially unsupported methods to be called. These methods return an UnsupportedCommand error, which we could easily conclude at compile-time rather than run-time. I think the easiest and most intuitive way around this would be to make separate structs for each of the three channel modes and only add the allowed methods for that channel mode to each struct. I'm happy to work on it too, if you like the idea!

pleshevskiy commented 3 years ago

Thank you for your response. I didn't think about the problem. In fact, it won't take much time to rewrite to separated structures.