[feat](trx-backend): add register_builtin_backends_on for context initialization

Add register_builtin_backends_on(context: &mut RegistrationContext) function
to allow explicit backend registration on a context instead of always using globals.

This enables proper initialization sequencing where backends are registered
on a specific context that can be passed through bootstrap.

The global register_builtin_backends() still works for plugin compatibility,
delegating to the new context-based approach.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
2026-02-12 20:49:37 +01:00
parent d8e9397cf6
commit 0a8a98ea54
2 changed files with 22 additions and 2 deletions
+10 -1
View File
@@ -105,7 +105,16 @@ pub fn register_backend(name: &str, factory: BackendFactory) {
reg.factories.insert(key, factory);
}
/// Register all built-in backends enabled by features.
/// Register all built-in backends enabled by features on a context.
pub fn register_builtin_backends_on(context: &mut RegistrationContext) {
context.register_backend("dummy", dummy_factory);
#[cfg(feature = "ft817")]
context.register_backend("ft817", ft817_factory);
#[cfg(feature = "ft450d")]
context.register_backend("ft450d", ft450d_factory);
}
/// Register all built-in backends enabled by features (global, for plugin compatibility).
pub fn register_builtin_backends() {
register_backend("dummy", dummy_factory);
#[cfg(feature = "ft817")]