In C++
one way to handle designing a program that needs to read multiple file formats is a Repository
of Factory
s of Strategy
s. Generally the Repository
part is a Singleton
. The Factory
takes care of building a Strategy
which handles the file format. Furthermore, the Repository
can be populated via static initialization, such that each Factory
can register itself to the Repository
before main()
is executed.
I'm struggling to see how to implement a similar system, without the Singleton
component, in Rust
. What I'd like is to be able to register Factory
s to some kind of file reader repository, ideally at static initialization time, with the added option for other modules or plug-ins to be able to add their own file readers at runtime.
Aucun commentaire:
Enregistrer un commentaire