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
It seems to me like it is unnecessary to use a trait object here when the struct PluginRegistrar could be used directly.
This would require that the core module implements and exports both struct FunctionProxy and struct PluginRegistrar to be used in app. Am I missing something that prevents this or is it a matter of preference?
The text was updated successfully, but these errors were encountered:
@seatonullberg I think it comes down to two things. First, having a trait PluginRegistrar allows for alternative implementations that depend on the app. Second, struct PluginRegistrar has a field lib: Rc<Library> that gets cloned to a FunctionProxy for every registered function, which means it depends on the libloading crate, and including the struct directly in plugins_core will add an unnecessary dependency of libloading to every plugin using plugins_core.
Thank you for making this tutorial, it has been a huge help for me!
My only point of confusion has been with the use of
PluginRegistrar
as a trait object inrandom/src/lib.rs
:Then
trait PluginRegistrar
is implemented forstruct PluginRegistrar
inapp/src/main.rs
:And that is the only implementation.
It seems to me like it is unnecessary to use a trait object here when the
struct PluginRegistrar
could be used directly.This would require that the
core
module implements and exports bothstruct FunctionProxy
andstruct PluginRegistrar
to be used inapp
. Am I missing something that prevents this or is it a matter of preference?The text was updated successfully, but these errors were encountered: