Skip to main content

RegistryWriter

Struct RegistryWriter 

Source
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

Source

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.

Source

pub fn with_handler_factory(factory: HandlerFactory) -> Self

Create a RegistryWriter with a custom handler factory for target resolution.

Source

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

Source

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.

Trait Implementations§

Source§

impl Default for RegistryWriter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more