but only really works if the data looks like this {}
So what's a nice, Swifty way to address this? Haven't tried Empty to handle nothing by overriding the init(decoder)... not sure if that's possible yet.
(alternatively, drop Result and pass an Error? to the callback)
The downside to this is that it can lead to ambiguities during type inference/overload resolution, but since you're not using the generic parameter elsewhere in your signature, I'm guessing you have to manually write the types in the callback anyway. e.g:
Alamofire includes an Empty type for exactly this purpose, as well as an EmptyResponse protocol, so that types can define their own empty value. In our included response serializers we check to see if an empty response is allowed, and, if so, attempt to cast the relevant empty type. It's not super elegant, but it lets us represent it in the type system.
Let me walk this back, actually. I think Result’s “success” case with a Void payload is much clearer than saying “a request whose callback is given a nil error implicitly succeeded”. Clearer APIs mean fewer mistakes.