This is a proof-of-concept for a mechanism that does away with the need to list all NIF functions in the rustler::init! invocation. A similar mechanism will be required and implemented for resource type registrations.
Convert Nif to a struct
Use inventory to register the Nif instances
In rustler::init!, ignore the passed functions and instead use the registered Nif instances
Next steps:
[x] See whether linkme is not a better option (creates the array directly at build-time, no need to leak) (/edit Looking at this again, don't think this adds much, the current implementation is fine)
[x] Implement resource registration using this mechanism (#617)
[ ] See if we can move the macros to rustler (might do this in another iteration, no need to put it in the same PR)
This is a proof-of-concept for a mechanism that does away with the need to list all NIF functions in the
rustler::init!
invocation. A similar mechanism will be required and implemented for resource type registrations.Nif
to astruct
inventory
to register theNif
instancesrustler::init!
, ignore the passed functions and instead use the registeredNif
instancesNext steps:
linkme
is not a better option (creates the array directly at build-time, no need to leak) (/edit Looking at this again, don't think this adds much, the current implementation is fine)rustler
(might do this in another iteration, no need to put it in the same PR)