You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a thought that I had while fixing a bug I'd made...
We have the request::ApiRequest type which specifies some data for the request type. It should be possible to make an associated type request::ApiRequest::Response to link the response type to a particular request type. Then the type of client::IpfsClient::request<Req, Res>() -> AsyncResponse<Res> could just become client::IpfsClient::request<Req>() -> AsyncResponse<Req::Response>.
That wouldn't have prevented the bug that I'd made, I would have just put the typo in a different spot, so I'm not sure if this will actually help rather than just bikeshedding. But maybe it could make life a little simpler?
...actually, now that I think about it, we might be able to make the ApiRequest::path() method be an associated const now. Though that might be more restrictive than we want? I dunno.
The text was updated successfully, but these errors were encountered:
Yeah, I like the idea of the associated type. I was planning on making a macro to implement the ApiRequest trait, since a large portion of it is just boiler plate. Since I was pretty consistent with the type naming, I think it might be possible to make a macro where you just pass in the request name, and it would automatically link the response as an associated type. I think a combination of the associated type, and the macro would make it really difficult to ever make a naming issue.
Also I'm okay with making path an associated const. I didn't know about associated consts, but the path method is pretty much acting like one right now.
I think it might be possible to make a macro where you just pass in the request name, and it would automatically link the response as an associated type
Let me know if you work this out, but afaik synthesizing new identifiers in macros is not currently feasible... :-(
Just a thought that I had while fixing a bug I'd made...
We have the
request::ApiRequest
type which specifies some data for the request type. It should be possible to make an associated typerequest::ApiRequest::Response
to link the response type to a particular request type. Then the type ofclient::IpfsClient::request<Req, Res>() -> AsyncResponse<Res>
could just becomeclient::IpfsClient::request<Req>() -> AsyncResponse<Req::Response>
.That wouldn't have prevented the bug that I'd made, I would have just put the typo in a different spot, so I'm not sure if this will actually help rather than just bikeshedding. But maybe it could make life a little simpler?
...actually, now that I think about it, we might be able to make the
ApiRequest::path()
method be an associated const now. Though that might be more restrictive than we want? I dunno.The text was updated successfully, but these errors were encountered: