Closed EpokTarren closed 1 month ago
Default
for model::Request
. IIRC I originally did this to just cut down on boilerplate, hence the many instances of ..Default::default()
. I think it should be removed and changes made as you suggest, although ideally in a way that saves on boilerplate, if possible. impl Into<GetRequest>
idea; I was aware that many of these requests were quite simple, but didn't realise you could do this. I wanted to make sure the signature of the API methods was relatively uniform, constant, and relied on a single source of truth (one struct). This change would make it easier to construct them while also preserving that.Request
s that are simply constructed and passed through, I agree it would make sense to just move them into the method body instead.Thanks for your feedback :)
Currently the following code compiles, it does not have what I would imagine is the expected behaviour, instead the final line will always error, this part of the crate API feels like a footgun.
My suggestion is that
model::Request
shouldn't implementDefault
directly, instead for types such asmodel::account::profile::GetRequest
should implement so that the request is properly formed, mainly the path is currently missing. For request types such asmodel::messaging::inbox::PostRequest
it would make sense not to implementDefault
at all. Do methods which take no arguments need a to accept a request type or could it be generated in the method body?For methods such as
client::LichessApi::tv_channel_games
that only have one required parameter, could they accept only that in addition to the full type usingFrom
/Into
, example code below.Would these changes be desirable contributions to the project?