pub struct RegistryWriter { /* private fields */ }Expand description
Registers ScannedModule instances directly into an apcore Registry.
This is the default writer used when no output_format is specified. Instead of writing files, it registers modules directly for immediate use.
§Handler Resolution
By default (RegistryWriter::new()), modules are registered with a passthrough
handler that returns inputs unchanged — useful for schema-only registration
where execution is handled elsewhere.
For executable modules, use RegistryWriter::with_handler_factory(factory) to
provide a HandlerFactory that resolves target strings to real handlers.
Implementations§
Source§impl RegistryWriter
impl RegistryWriter
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a RegistryWriter with passthrough handlers (schema-only registration).
§Handler resolution
Unlike the Python and TypeScript implementations which dynamically import
the target function at write time (resolve_target), the Rust implementation
registers a passthrough handler that echoes its inputs when no HandlerFactory
is configured. This means calling a module registered by this writer will
succeed but will not execute real business logic. To register real handlers,
use the HandlerFactory integration.
§Panics
This constructor does not panic. However, note that without a HandlerFactory,
all registered modules will use a passthrough handler that echoes inputs unchanged.
This is suitable for schema-only registration. For real execution, use
RegistryWriter::with_handler_factory to supply a factory that resolves targets
to actual async handlers.
Sourcepub fn with_handler_factory(factory: HandlerFactory) -> Self
pub fn with_handler_factory(factory: HandlerFactory) -> Self
Create a RegistryWriter with a custom handler factory for target resolution.
Sourcepub fn with_allowed_prefixes(self, prefixes: Vec<String>) -> Self
pub fn with_allowed_prefixes(self, prefixes: Vec<String>) -> Self
Restrict registration to modules whose target starts with one of the
supplied prefixes. Modules with a non-matching target are rejected with
a failed WriteResult and never reach the handler factory.
Matches the allowed_prefixes parameter on the Python RegistryWriter
and the TypeScript allowedPrefixes option. Use it to bound the set of
callable Python/Rust paths a binding YAML may resolve to (defence in
depth against forged or attacker-controlled target strings).
Source§impl RegistryWriter
impl RegistryWriter
Sourcepub fn write(
&self,
modules: &[ScannedModule],
registry: &mut Registry,
dry_run: bool,
verify: bool,
verifiers: Option<&[&dyn Verifier]>,
) -> Vec<WriteResult>
pub fn write( &self, modules: &[ScannedModule], registry: &mut Registry, dry_run: bool, verify: bool, verifiers: Option<&[&dyn Verifier]>, ) -> Vec<WriteResult>
Register scanned modules into the registry.
registry: The apcore Registry to register modules into.dry_run: If true, skip registration and return results only.verify: If true, verify modules are retrievable after registration.verifiers: Optional custom verifiers run after the built-in check.
§Verifier contract for registry-based modules
Registry modules have no output file, so custom verifiers receive
path = "". Built-in file-based verifiers (YAMLVerifier, JSONVerifier,
etc.) skip gracefully when path is empty. Custom verifiers must also
handle path = "" without erroring — use module_id for any
registry-based checks.