Conversation
9549654 to
5f17f2e
Compare
5f17f2e to
5b1b387
Compare
|
The current implementation is enough for the usage or should we also implement it automatically in derive macro? EDIT: I feel it shouldn't be difficult, except for |
@gui1117 thank you very much for the review ! Yes, it would be nice to also implement it automatically. Normally it should be an auto trait, but this feature is still unstable so I couldn't use that. Implementing it automatically in the derive macros would be the next best thing, but I didn't manage to do it. For example for: I tried something that would expand to: Which generates compile errors. So probably we'll need to implement it manually for each custom struct. |
I see we can't derive it automatically with This macro will do the bound same as Encode/Decode, i.e. bound only the generic types. and it will fail if some concrete types don't implement It would still be more handy than manually write the code I guess. |
gui1117
left a comment
There was a problem hiding this comment.
I suggested some more types to implement the trait on.
But part from this it looks good to me.
I'm not sure if it's possible. Unless we add a mock method to the |
I see it now, indeed. :-/ |
gui1117
left a comment
There was a problem hiding this comment.
Looks good to me.
I still think requiring to implement it manually can be painful. But if the types requiring this are not many then it good.
bkchr
left a comment
There was a problem hiding this comment.
Did you try this will work on Substrate? I mean you will need to ensure that Call implements DecodeWithMemTracking and all the types we are using there.
Also you should expose a function decode_with_mem_limit instead of exposing the MemLimitInput
Oh, you're right. I can patch
Yes, will do this too. |
This reverts commit 5b1b387.
Yes, sorry, you're right. We need to be able to derive it since for types like |
Done. This compiles for
Done @bkchr Addressed all the comments. PTAL ! |
bkchr
left a comment
There was a problem hiding this comment.
Some last nitpicks. Otherwise it already looks good :)
|
@bkchr just wanted to check if you would like to take another look on the PR or if I could merge it as it is since it already has 2 approving reviews |
bkchr
left a comment
There was a problem hiding this comment.
Nice work 👍 Thank you for doing this!
Related to #609
Ended up with almost the same approach proposed by @ggwpez in #602, but made it type safe through a marker trait.
This is not a breaking change.
The inconvenience is that
DecodeWithMemTrackingwill need to be implemented manually for each struct.